diff options
Diffstat (limited to 'src/libcore/option.rs')
| -rw-r--r-- | src/libcore/option.rs | 18 | 
1 files changed, 18 insertions, 0 deletions
| diff --git a/src/libcore/option.rs b/src/libcore/option.rs index b7c51147fba..7cb40876705 100644 --- a/src/libcore/option.rs +++ b/src/libcore/option.rs @@ -101,9 +101,16 @@ impl<T: Copy + Add<T,T>> Add<Option<T>, Option<T>> for Option<T> { impl<T> BaseIter<T> for Option<T> { /// Performs an operation on the contained value by reference #[inline(always)] + #[cfg(stage0)] fn each<'a>(&'a self, f: &fn(x: &'a T) -> bool) { match *self { None => (), Some(ref t) => { f(t); } } } + /// Performs an operation on the contained value by reference + #[inline(always)] + #[cfg(not(stage0))] + fn each<'a>(&'a self, f: &fn(x: &'a T) -> bool) -> bool { + match *self { None => true, Some(ref t) => { f(t) } } + } #[inline(always)] fn size_hint(&self) -> Option<uint> { @@ -112,16 +119,27 @@ impl<T> BaseIter<T> for Option<T> { } impl<T> MutableIter<T> for Option<T> { + #[cfg(stage0)] #[inline(always)] fn each_mut<'a>(&'a mut self, f: &fn(&'a mut T) -> bool) { match *self { None => (), Some(ref mut t) => { f(t); } } } + #[cfg(not(stage0))] + #[inline(always)] + fn each_mut<'a>(&'a mut self, f: &fn(&'a mut T) -> bool) -> bool { + match *self { None => true, Some(ref mut t) => { f(t) } } + } } impl<A> ExtendedIter<A> for Option<A> { + #[cfg(stage0)] pub fn eachi(&self, blk: &fn(uint, v: &A) -> bool) { old_iter::eachi(self, blk) } + #[cfg(not(stage0))] + pub fn eachi(&self, blk: &fn(uint, v: &A) -> bool) -> bool { + old_iter::eachi(self, blk) + } pub fn all(&self, blk: &fn(&A) -> bool) -> bool { old_iter::all(self, blk) } | 
