Skip to content

Commit

Permalink
Merge pull request #275 from dtolnay/autotraits
Browse files Browse the repository at this point in the history
Impl Send + Sync for Identifier
  • Loading branch information
dtolnay committed May 2, 2022
2 parents bc69917 + 0768c69 commit 44f0ac4
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/identifier.rs
Expand Up @@ -249,6 +249,9 @@ impl PartialEq for Identifier {
}
}

unsafe impl Send for Identifier {}
unsafe impl Sync for Identifier {}

// We use heap pointers that are 2-byte aligned, meaning they have an
// insignificant 0 in the least significant bit. We take advantage of that
// unneeded bit to rotate a 1 into the most significant bit to make the repr
Expand Down
12 changes: 12 additions & 0 deletions tests/test_autotrait.rs
@@ -0,0 +1,12 @@
fn assert_send_sync<T: Send + Sync>() {}

#[test]
fn test() {
assert_send_sync::<semver::BuildMetadata>();
assert_send_sync::<semver::Comparator>();
assert_send_sync::<semver::Error>();
assert_send_sync::<semver::Prerelease>();
assert_send_sync::<semver::Version>();
assert_send_sync::<semver::VersionReq>();
assert_send_sync::<semver::Op>();
}

0 comments on commit 44f0ac4

Please sign in to comment.