summaryrefslogtreecommitdiff
path: root/examples/basic-fragile.rs
blob: 54e33fd9fc334bbc9e2ec9d399e556f2770362a9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
use std::thread;

use fragile::Fragile;

fn main() {
    // creating and using a fragile object in the same thread works
    let val = Fragile::new(true);
    println!("debug print in same thread: {:?}", &val);
    println!("try_get in same thread: {:?}", val.try_get());

    // once send to another thread it stops working
    thread::spawn(move || {
        println!("debug print in other thread: {:?}", &val);
        println!("try_get in other thread: {:?}", val.try_get());
    })
    .join()
    .unwrap();
}