diff --git a/src/libstd/collections/hash/set.rs b/src/libstd/collections/hash/set.rs index c6dcb0d230f..755235cbace 100644 --- a/src/libstd/collections/hash/set.rs +++ b/src/libstd/collections/hash/set.rs @@ -18,7 +18,9 @@ use default::Default; use fmt::Debug; use fmt; use hash::{self, Hash}; -use iter::{Iterator, ExactSizeIterator, IteratorExt, FromIterator, Map, Chain, Extend}; +use iter::{ + Iterator, IntoIterator, ExactSizeIterator, IteratorExt, FromIterator, Map, Chain, Extend, +}; use ops::{BitOr, BitAnd, BitXor, Sub}; use option::Option::{Some, None, self}; @@ -833,6 +835,30 @@ pub struct Union<'a, T: 'a, S: 'a> { iter: Chain, Difference<'a, T, S>> } +impl<'a, T, S, H> IntoIterator for &'a HashSet + where T: Eq + Hash, + S: HashState, + H: hash::Hasher +{ + type Iter = Iter<'a, T>; + + fn into_iter(self) -> Iter<'a, T> { + self.iter() + } +} + +impl IntoIterator for HashSet + where T: Eq + Hash, + S: HashState, + H: hash::Hasher +{ + type Iter = IntoIter; + + fn into_iter(self) -> IntoIter { + self.into_iter() + } +} + #[stable(feature = "rust1", since = "1.0.0")] impl<'a, K> Iterator for Iter<'a, K> { type Item = &'a K;