Guest User

Untitled

a guest
Oct 23rd, 2018
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.28 KB | None | 0 0
  1. struct A {
  2. x: [u32; 3],
  3. }
  4.  
  5. impl A {
  6. fn iter<'a>(&'a self) -> impl Iterator<Item=u32> + 'a {
  7. (0..3).filter(move |&i| self.x[i] != 0).map(move |i| self.x[i])
  8. }
  9. }
  10.  
  11. fn main() {
  12. let a = A { x : [0, 1, 2]};
  13. for el in a.iter() {
  14. println!("{}", el);
  15. }
  16. }
Add Comment
Please, Sign In to add comment