diff options
Diffstat (limited to '')
-rw-r--r-- | src/test/ui/issues/issue-41880.rs | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/src/test/ui/issues/issue-41880.rs b/src/test/ui/issues/issue-41880.rs new file mode 100644 index 000000000..977c43b71 --- /dev/null +++ b/src/test/ui/issues/issue-41880.rs @@ -0,0 +1,29 @@ +fn iterate<T, F>(initial: T, f: F) -> Iterate<T, F> { + Iterate { + state: initial, + f: f, + } +} + +pub struct Iterate<T, F> { + state: T, + f: F +} + +impl<T: Clone, F> Iterator for Iterate<T, F> where F: Fn(&T) -> T { + type Item = T; + + #[inline] + fn next(&mut self) -> Option<Self::Item> { + self.state = (self.f)(&self.state); + Some(self.state.clone()) + } + #[inline] + fn size_hint(&self) -> (usize, Option<usize>) { (usize::MAX, None) } +} + +fn main() { + let a = iterate(0, |x| x+1); + println!("{:?}", a.iter().take(10).collect::<Vec<usize>>()); + //~^ ERROR no method named `iter` found +} |