diff options
| author | Guillaume Gomez <guillaume1.gomez@gmail.com> | 2015-08-09 21:04:22 +0200 |
|---|---|---|
| committer | Guillaume Gomez <guillaume1.gomez@gmail.com> | 2015-08-10 22:46:58 +0200 |
| commit | a4e4233828f0a8cb30278245d53dcb25b2e26a01 (patch) | |
| tree | 01402d0638fd57cdade151d091734a69839fb854 /src/libstd | |
| parent | a5d33d8911d3ea691cb152bc582ee443ae3619da (diff) | |
| download | rust-a4e4233828f0a8cb30278245d53dcb25b2e26a01.tar.gz rust-a4e4233828f0a8cb30278245d53dcb25b2e26a01.zip | |
Add Send/Sync traits on Iter struct in hash/table
Diffstat (limited to 'src/libstd')
| -rw-r--r-- | src/libstd/collections/hash/set.rs | 23 | ||||
| -rw-r--r-- | src/libstd/collections/hash/table.rs | 3 |
2 files changed, 25 insertions, 1 deletions
diff --git a/src/libstd/collections/hash/set.rs b/src/libstd/collections/hash/set.rs index fb594dadd73..445391bbe3a 100644 --- a/src/libstd/collections/hash/set.rs +++ b/src/libstd/collections/hash/set.rs @@ -11,7 +11,7 @@ use borrow::Borrow; use clone::Clone; use cmp::{Eq, PartialEq}; -use core::marker::Sized; +use core::marker::{Sized, Send, Sync}; use default::Default; use fmt::Debug; use fmt; @@ -764,18 +764,27 @@ pub struct Iter<'a, K: 'a> { iter: Keys<'a, K, ()> } +unsafe impl<'a, K: Send> Send for Iter<'a, K> {} +unsafe impl<'a, K: Sync> Sync for Iter<'a, K> {} + /// HashSet move iterator #[stable(feature = "rust1", since = "1.0.0")] pub struct IntoIter<K> { iter: Map<map::IntoIter<K, ()>, fn((K, ())) -> K> } +unsafe impl<K: Send> Send for IntoIter<K> {} +unsafe impl<K: Sync> Sync for IntoIter<K> {} + /// HashSet drain iterator #[stable(feature = "rust1", since = "1.0.0")] pub struct Drain<'a, K: 'a> { iter: Map<map::Drain<'a, K, ()>, fn((K, ())) -> K>, } +unsafe impl<'a, K: Send> Send for Drain<'a, K> {} +unsafe impl<'a, K: Sync> Sync for Drain<'a, K> {} + /// Intersection iterator #[stable(feature = "rust1", since = "1.0.0")] pub struct Intersection<'a, T: 'a, S: 'a> { @@ -785,6 +794,9 @@ pub struct Intersection<'a, T: 'a, S: 'a> { other: &'a HashSet<T, S>, } +unsafe impl<'a, K: Send, S: Send> Send for Intersection<'a, K, S> {} +unsafe impl<'a, K: Sync, S: Send> Sync for Intersection<'a, K, S> {} + /// Difference iterator #[stable(feature = "rust1", since = "1.0.0")] pub struct Difference<'a, T: 'a, S: 'a> { @@ -794,18 +806,27 @@ pub struct Difference<'a, T: 'a, S: 'a> { other: &'a HashSet<T, S>, } +unsafe impl<'a, K: Send, S: Send> Send for Difference<'a, K, S> {} +unsafe impl<'a, K: Sync, S: Send> Sync for Difference<'a, K, S> {} + /// Symmetric difference iterator. #[stable(feature = "rust1", since = "1.0.0")] pub struct SymmetricDifference<'a, T: 'a, S: 'a> { iter: Chain<Difference<'a, T, S>, Difference<'a, T, S>> } +unsafe impl<'a, K: Send, S: Send> Send for SymmetricDifference<'a, K, S> {} +unsafe impl<'a, K: Sync, S: Send> Sync for SymmetricDifference<'a, K, S> {} + /// Set union iterator. #[stable(feature = "rust1", since = "1.0.0")] pub struct Union<'a, T: 'a, S: 'a> { iter: Chain<Iter<'a, T>, Difference<'a, T, S>> } +unsafe impl<'a, K: Send, S: Send> Send for Union<'a, K, S> {} +unsafe impl<'a, K: Sync, S: Send> Sync for Union<'a, K, S> {} + #[stable(feature = "rust1", since = "1.0.0")] impl<'a, T, S> IntoIterator for &'a HashSet<T, S> where T: Eq + Hash, S: HashState diff --git a/src/libstd/collections/hash/table.rs b/src/libstd/collections/hash/table.rs index 349462aebe3..ee63e29e6c9 100644 --- a/src/libstd/collections/hash/table.rs +++ b/src/libstd/collections/hash/table.rs @@ -741,6 +741,9 @@ struct RawBuckets<'a, K, V> { marker: marker::PhantomData<&'a ()>, } +unsafe impl<'a, K: Send, V: Send> Send for RawBuckets<'a, K, V> {} +unsafe impl<'a, K: Sync, V: Sync> Sync for RawBuckets<'a, K, V> {} + // FIXME(#19839) Remove in favor of `#[derive(Clone)]` impl<'a, K, V> Clone for RawBuckets<'a, K, V> { fn clone(&self) -> RawBuckets<'a, K, V> { |
