Created
February 19, 2019 20:51
-
-
Save tzemanovic/d60fcff8274be5bf51fde423f73c3f18 to your computer and use it in GitHub Desktop.
doubler.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
struct Doubler<I: Iterator> { | |
iter: I, | |
} | |
impl<I> Iterator for Doubler<I> | |
where | |
I: Iterator, | |
I::Item: std::ops::Add<Output = I::Item> + Copy, | |
{ | |
type Item = I::Item; | |
fn next(&mut self) -> Option<<Self as Iterator>::Item> { | |
self.iter.next().map(|x| x + x) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment