Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- pub enum Thing {
- Foo { y: u64 },
- Bar { z: u64 },
- }
- pub struct Things {
- pub things: Vec<Thing>,
- }
- impl Things {
- fn tick(&mut self) {
- for thing in self.things.iter_mut() {
- match thing {
- Thing::Foo { y } => {
- y -= 1;
- },
- Thing::Bar { z } => {
- z += 1;
- },
- }
- }
- }
- }
- fn main() {
- let mut things = Things {
- things: Vec::new()
- };
- things.things.push(Thing::Foo { y: 1 });
- things.things.push(Thing::Bar { z: 1 });
- things.tick();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement