Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #[derive(Debug)]
- struct Foo {
- val: u8,
- }
- fn main() {
- let mut f = Foo { val: 0 };
- let mut funcs: [Box<dyn FnMut()>; 3] = [
- Box::new(|| { f.val = 3; }),
- Box::new(|| { f.val = 10; }),
- Box::new(|| { f.val = 1; }),
- ];
- for fun in &mut funcs {
- fun();
- }
- println!("{:?}", f);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement