Advertisement
Guest User

Untitled

a guest
Jul 23rd, 2019
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.60 KB | None | 0 0
  1. pub enum Thing {
  2. Foo { y: u64 },
  3. Bar { z: u64 },
  4. }
  5. pub struct Things {
  6. pub things: Vec<Thing>,
  7. }
  8.  
  9. impl Things {
  10. fn tick(&mut self) {
  11. for thing in self.things.iter_mut() {
  12. match thing {
  13. Thing::Foo { y } => {
  14. y -= 1;
  15. },
  16. Thing::Bar { z } => {
  17. z += 1;
  18. },
  19. }
  20. }
  21. }
  22. }
  23.  
  24. fn main() {
  25. let mut things = Things {
  26. things: Vec::new()
  27. };
  28. things.things.push(Thing::Foo { y: 1 });
  29. things.things.push(Thing::Bar { z: 1 });
  30. things.tick();
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement