take-once
A thread-safe container for one-time storage and one-time consumption of a value.
Usage
use TakeOnce;
let cell = new;
// Initial store succeeds
assert_eq!;
// Subsequent stores return the provided value
assert_eq!;
// Take the value
assert_eq!;
// Can't take twice
assert_eq!;
// Can be used across threads via `Arc`
use Arc;
use thread;
let cell = new;
let cell_clone = cell.clone;
let handle = spawn;
handle.join.unwrap;
assert_eq!;
See the documentation for more details.
Testing
This crate uses shuttle for (more) exhaustive testing. To run the shuttle tests, run:
License
MIT