impl IntoIterator for HashSet
This commit is contained in:
parent
afabb022b0
commit
9f90d666e0
@ -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<Iter<'a, T>, Difference<'a, T, S>>
|
||||
}
|
||||
|
||||
impl<'a, T, S, H> IntoIterator for &'a HashSet<T, S>
|
||||
where T: Eq + Hash<H>,
|
||||
S: HashState<Hasher=H>,
|
||||
H: hash::Hasher<Output=u64>
|
||||
{
|
||||
type Iter = Iter<'a, T>;
|
||||
|
||||
fn into_iter(self) -> Iter<'a, T> {
|
||||
self.iter()
|
||||
}
|
||||
}
|
||||
|
||||
impl<T, S, H> IntoIterator for HashSet<T, S>
|
||||
where T: Eq + Hash<H>,
|
||||
S: HashState<Hasher=H>,
|
||||
H: hash::Hasher<Output=u64>
|
||||
{
|
||||
type Iter = IntoIter<T>;
|
||||
|
||||
fn into_iter(self) -> IntoIter<T> {
|
||||
self.into_iter()
|
||||
}
|
||||
}
|
||||
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
impl<'a, K> Iterator for Iter<'a, K> {
|
||||
type Item = &'a K;
|
||||
|
Loading…
x
Reference in New Issue
Block a user