Crates.io | fragile |
lib.rs | fragile |
version | 1.2.2 |
source | src |
created_at | 2018-06-20 23:57:55.033266 |
updated_at | 2022-10-18 20:36:16.56158 |
description | Provides wrapper types for sending non-send values to other threads. |
homepage | https://github.com/mitsuhiko/fragile |
repository | https://github.com/mitsuhiko/fragile |
max_upload_size | |
id | 71014 |
size | 28,288 |
This library provides wrapper types that permit sending non Send types to other threads and use runtime checks to ensure safety.
use std::thread;
// creating and using a fragile object in the same thread works
let val = Fragile::new(true);
assert_eq!(*val.get(), true);
assert!(val.try_get().is_ok());
// once send to another thread it stops working
thread::spawn(move || {
assert!(val.try_get().is_err());
}).join()
.unwrap();