diff options
| author | Jorge Aparicio <japaricious@gmail.com> | 2015-01-07 22:01:05 -0500 |
|---|---|---|
| committer | Jorge Aparicio <japaricious@gmail.com> | 2015-01-30 10:36:31 -0500 |
| commit | a65d3f5b98cc94f0a759fbf1a08be9aee0f97883 (patch) | |
| tree | 727f2112924bbe042cb6a1ea059d163044ace818 /src/libcollections/enum_set.rs | |
| parent | 1a51eb9cca3ae5f815825096de4dfbdc9267f735 (diff) | |
| download | rust-a65d3f5b98cc94f0a759fbf1a08be9aee0f97883.tar.gz rust-a65d3f5b98cc94f0a759fbf1a08be9aee0f97883.zip | |
core: add the `IntoIterator` trait
Diffstat (limited to 'src/libcollections/enum_set.rs')
| -rw-r--r-- | src/libcollections/enum_set.rs | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/src/libcollections/enum_set.rs b/src/libcollections/enum_set.rs index b542259eba0..a9e64a5c282 100644 --- a/src/libcollections/enum_set.rs +++ b/src/libcollections/enum_set.rs @@ -16,7 +16,7 @@ use core::prelude::*; use core::fmt; use core::num::Int; -use core::iter::FromIterator; +use core::iter::{FromIterator, IntoIterator}; use core::ops::{Sub, BitOr, BitAnd, BitXor}; // FIXME(contentions): implement union family of methods? (general design may be wrong here) @@ -256,6 +256,14 @@ impl<E:CLike> FromIterator<E> for EnumSet<E> { } } +impl<'a, E> IntoIterator for &'a EnumSet<E> where E: CLike { + type Iter = Iter<E>; + + fn into_iter(self) -> Iter<E> { + self.iter() + } +} + impl<E:CLike> Extend<E> for EnumSet<E> { fn extend<I: Iterator<Item=E>>(&mut self, mut iterator: I) { for element in iterator { |
