Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions src/libcore/iter/traits/iterator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2703,9 +2703,23 @@ fn select_fold1<I, F>(mut it: I, mut f: F) -> Option<I::Item>
#[stable(feature = "rust1", since = "1.0.0")]
impl<I: Iterator + ?Sized> Iterator for &mut I {
type Item = I::Item;
default fn next(&mut self) -> Option<I::Item> { (**self).next() }
default fn size_hint(&self) -> (usize, Option<usize>) { (**self).size_hint() }
default fn nth(&mut self, n: usize) -> Option<Self::Item> {
(**self).nth(n)
}
}

#[stable(feature = "rust1", since = "1.0.0")]
impl<I: Iterator + Sized> Iterator for &mut I {
fn next(&mut self) -> Option<I::Item> { (**self).next() }
fn size_hint(&self) -> (usize, Option<usize>) { (**self).size_hint() }
fn nth(&mut self, n: usize) -> Option<Self::Item> {
(**self).nth(n)
}
fn try_fold<B, F, R>(&mut self, init: B, f: F) -> R where
F: FnMut(B, Self::Item) -> R, R: Try<Ok=B>
{
(**self).try_fold(init, f)
}
}
1 change: 0 additions & 1 deletion src/test/ui/issues/issue-31173.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ LL | .collect();
| ^^^^^^^
|
= note: the method `collect` exists but the following trait bounds were not satisfied:
`&mut std::iter::Cloned<std::iter::TakeWhile<&mut std::vec::IntoIter<u8>, [closure@$DIR/issue-31173.rs:6:39: 9:6 found_e:_]>> : std::iter::Iterator`
`std::iter::Cloned<std::iter::TakeWhile<&mut std::vec::IntoIter<u8>, [closure@$DIR/issue-31173.rs:6:39: 9:6 found_e:_]>> : std::iter::Iterator`

error: aborting due to 2 previous errors
Expand Down
2 changes: 0 additions & 2 deletions src/test/ui/methods/method-call-err-msg.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,6 @@ LL | pub struct Foo;
LL | .take()
| ^^^^
|
= note: the method `take` exists but the following trait bounds were not satisfied:
`&mut Foo : std::iter::Iterator`
= help: items from traits can only be used if the trait is implemented and in scope
= note: the following traits define an item `take`, perhaps you need to implement one of them:
candidate #1: `std::io::Read`
Expand Down
1 change: 0 additions & 1 deletion src/test/ui/mismatched_types/issue-36053-2.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ LL | once::<&str>("str").fuse().filter(|a: &str| true).count();
| ^^^^^
|
= note: the method `count` exists but the following trait bounds were not satisfied:
`&mut std::iter::Filter<std::iter::Fuse<std::iter::Once<&str>>, [closure@$DIR/issue-36053-2.rs:7:39: 7:53]> : std::iter::Iterator`
`std::iter::Filter<std::iter::Fuse<std::iter::Once<&str>>, [closure@$DIR/issue-36053-2.rs:7:39: 7:53]> : std::iter::Iterator`

error[E0631]: type mismatch in closure arguments
Expand Down