| 1 | use std::thread; |
| 2 | |
| 3 | use fragile::Fragile; |
| 4 | |
| 5 | fn main() { |
| 6 | // creating and using a fragile object in the same thread works |
| 7 | let val = Fragile::new(true); |
| 8 | println!("debug print in same thread: {:?}" , &val); |
| 9 | println!("try_get in same thread: {:?}" , val.try_get()); |
| 10 | |
| 11 | // once send to another thread it stops working |
| 12 | thread::spawn(move || { |
| 13 | println!("debug print in other thread: {:?}" , &val); |
| 14 | println!("try_get in other thread: {:?}" , val.try_get()); |
| 15 | }) |
| 16 | .join() |
| 17 | .unwrap(); |
| 18 | } |
| 19 | |