Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- struct A {
- x: [u32; 3],
- }
- impl A {
- fn iter<'a>(&'a self) -> impl Iterator<Item=u32> + 'a {
- (0..3).filter(move |&i| self.x[i] != 0).map(move |i| self.x[i])
- }
- }
- fn main() {
- let a = A { x : [0, 1, 2]};
- for el in a.iter() {
- println!("{}", el);
- }
- }
Add Comment
Please, Sign In to add comment