Guest User

Untitled

a guest
Jun 18th, 2018
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.43 KB | None | 0 0
  1. struct Foo {
  2. b: Bar,
  3. z: Baz,
  4. }
  5.  
  6. struct Bar {
  7. n: u32,
  8. }
  9.  
  10. impl Bar {
  11. fn eat(self) -> u32 {
  12. self.n
  13. }
  14. }
  15.  
  16. struct Baz {
  17. c: char,
  18. }
  19.  
  20. impl Baz {
  21. fn get(&self) -> char {
  22. self.c
  23. }
  24. }
  25.  
  26. fn close<F>(f: F) -> char
  27. where F: Fn() -> char {
  28. f()
  29. }
  30.  
  31. fn main() {
  32. let f = Foo{
  33. b: Bar{ n: 12u32 },
  34. z: Baz{ c: 'a' },
  35. };
  36. let _n = f.b.eat();
  37. let z = f.z;
  38. close(|| z.get() );
  39. }
Add Comment
Please, Sign In to add comment