Skip to content

Commit

Permalink
add Send and Sync as appropriate
Browse files Browse the repository at this point in the history
  • Loading branch information
cammeresi committed Jun 5, 2024
1 parent d30efb2 commit 887a99a
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ where
}

impl<T> std::iter::FusedIterator for LinkerSetIter<T> where T: 'static {}
unsafe impl<T: Send> Send for LinkerSetIter<T> {}

pub struct LinkerSet<T>
where
Expand Down Expand Up @@ -104,6 +105,9 @@ where
}
}

unsafe impl<T: Send> Send for LinkerSet<T> {}
unsafe impl<T: Sync> Sync for LinkerSet<T> {} // readonly once created

#[macro_export]
macro_rules! set_declare {
($set:ident, $type:ty) => {
Expand Down Expand Up @@ -207,6 +211,16 @@ mod test {
let expect = HashSet::from([&AAA]);
assert_eq!(actual, expect);
}

#[test]
fn test_traits() {
fn require_send<T: Send>(_: T) {}
fn require_sync<T: Sync>(_: T) {}

require_send(set!(aaa));
require_sync(set!(aaa));
require_send(set!(aaa).iter());
}
}

#[cfg(test)]
Expand Down

0 comments on commit 887a99a

Please sign in to comment.