From 74e111caf6d9634917f77977a4e51e562498be87 Mon Sep 17 00:00:00 2001 From: Jorge Aparicio Date: Mon, 19 Jan 2015 09:48:05 -0500 Subject: impl Iterator for &mut Iterator and Box closes #20953 closes #21361 --- src/liballoc/boxed.rs | 11 +++++++++++ src/liballoc/lib.rs | 2 ++ 2 files changed, 13 insertions(+) (limited to 'src/liballoc') diff --git a/src/liballoc/boxed.rs b/src/liballoc/boxed.rs index 8ad0c152dc8..89de2c953e4 100644 --- a/src/liballoc/boxed.rs +++ b/src/liballoc/boxed.rs @@ -18,6 +18,7 @@ use core::cmp::{PartialEq, PartialOrd, Eq, Ord, Ordering}; use core::default::Default; use core::fmt; use core::hash::{self, Hash}; +use core::iter::Iterator; use core::marker::Sized; use core::mem; use core::option::Option; @@ -185,6 +186,16 @@ impl DerefMut for Box { fn deref_mut(&mut self) -> &mut T { &mut **self } } +// FIXME(#21363) remove `old_impl_check` when bug is fixed +#[old_impl_check] +impl<'a, T> Iterator for Box + 'a> { + type Item = T; + + fn next(&mut self) -> Option { + (**self).next() + } +} + #[cfg(test)] mod test { #[test] diff --git a/src/liballoc/lib.rs b/src/liballoc/lib.rs index 811e32e747d..47715fe9e5d 100644 --- a/src/liballoc/lib.rs +++ b/src/liballoc/lib.rs @@ -70,6 +70,8 @@ #![feature(lang_items, unsafe_destructor)] #![feature(box_syntax)] #![feature(optin_builtin_traits)] +// FIXME(#21363) remove `old_impl_check` when bug is fixed +#![feature(old_impl_check)] #![allow(unknown_features)] #![feature(int_uint)] #[macro_use] -- cgit 1.4.1-3-g733a5 From 00cddb068c4cb17a91cca646103e0fba8c0a8077 Mon Sep 17 00:00:00 2001 From: Jorge Aparicio Date: Tue, 20 Jan 2015 18:15:28 -0500 Subject: also forward Iterator::size_hint() --- src/liballoc/boxed.rs | 4 ++++ src/libcore/iter.rs | 4 ++++ 2 files changed, 8 insertions(+) (limited to 'src/liballoc') diff --git a/src/liballoc/boxed.rs b/src/liballoc/boxed.rs index 89de2c953e4..7965c00a365 100644 --- a/src/liballoc/boxed.rs +++ b/src/liballoc/boxed.rs @@ -194,6 +194,10 @@ impl<'a, T> Iterator for Box + 'a> { fn next(&mut self) -> Option { (**self).next() } + + fn size_hint(&self) -> (usize, Option) { + (**self).size_hint() + } } #[cfg(test)] diff --git a/src/libcore/iter.rs b/src/libcore/iter.rs index 3d51f75d9b3..2a21ceef7a1 100644 --- a/src/libcore/iter.rs +++ b/src/libcore/iter.rs @@ -107,6 +107,10 @@ impl<'a, T> Iterator for &'a mut (Iterator + 'a) { fn next(&mut self) -> Option { (**self).next() } + + fn size_hint(&self) -> (usize, Option) { + (**self).size_hint() + } } /// Conversion from an `Iterator` -- cgit 1.4.1-3-g733a5