Created
January 18, 2018 10:54
-
-
Save anonymous/6eb992ed912f80bf482431f9a149e992 to your computer and use it in GitHub Desktop.
Rust code shared from the playground
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
use std::ops::Add; | |
pub struct SomeStruct<T> { | |
a: T, | |
b: T, | |
} | |
impl<T: Add<Output = T>> Iterator for SomeStruct<T> { | |
type Item = T; | |
fn next(&mut self) -> Option<Self::Item> { | |
let res: T = self.b + self.b; | |
Some(res) | |
} | |
} | |
fn main() { | |
println!("{}", (SomeStruct { a: 4, b: 9 }).next().unwrap()); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment