Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- use std::thread;
- use std::time::Duration;
- struct Example {
- prop: String,
- }
- impl Example {
- fn run(self: &Self) -> String {
- return self.prop;
- }
- }
- fn main() {
- let mut examples: Vec<&Example> = vec![];
- let example = Example { prop: "hello".to_string() };
- examples.push(&example);
- loop {
- start_loop(&mut examples);
- }
- unreachable!();
- }
- fn start_loop(examples: &'static mut Vec<&Example>) {
- // loop {
- for example in examples {
- example.prop = "world".to_string();
- thread::spawn(move || {
- example.run();
- });
- }
- thread::sleep(Duration::from_millis(1));
- // }
- // unreachable!();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement