Advertisement
Guest User

Untitled

a guest
Apr 21st, 2019
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.18 KB | None | 0 0
  1. #[derive(Debug)]
  2. struct Foo(u32);
  3.  
  4.  
  5. impl Foo {
  6. fn succ(self) -> Self {
  7. Self(self.0 + 1)
  8. }
  9. }
  10.  
  11. fn main() {
  12. (0..4).fold(Foo(0), |f, _| { println!("{:?}",f); f.succ() });
  13. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement