Created
April 7, 2022 00:56
-
-
Save Verdagon/225b3d4b646530294fcb6fea91c6991a to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
struct Account { | |
name: String, | |
money: i64, | |
labelView: i32 | |
} | |
struct Button { | |
onclick: Box<dyn FnMut()> | |
} | |
fn main() { | |
// Make some accounts. | |
let mut accounts = vec![ | |
Account { name: "Bob".to_string(), money: 100, labelView: 0 }, | |
Account { name: "Cindy".to_string(), money: 100, labelView: 0 }, | |
Account { name: "Reginald".to_string(), money: 100, labelView: 0 }, | |
Account { name: "Jim Argalax".to_string(), money: 100, labelView: 0 }, | |
Account { name: "Valerian Vast".to_string(), money: 100, labelView: 0 }, | |
Account { name: "Archonicus Auriarch".to_string(), money: 100, labelView: 0 } | |
]; | |
let mut page = Vec::new(); | |
for mut account in &mut accounts { | |
let button = Button { onclick: Box::new(|| { | |
account.money = account.money + 10; | |
})}; | |
page.push(button); | |
} | |
page.push(Button { onclick: Box::new(|| { | |
for mut account in &mut accounts { | |
account.money = account.money + 10; | |
} | |
})}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment