Expand description
Thread-safe, one-shot initialization with explicit winner status.
The first successfully completed initializer publishes one immutable value. Every later caller receives that value without evaluating its initializer.
use ma_ippatsu_r::{Ippatsu, ShotStatus};
let answer = Ippatsu::new();
assert_eq!(answer.fire(|| 42).status(), ShotStatus::FiredNow);
assert_eq!(answer.fire(|| 99).status(), ShotStatus::AlreadyFired);
assert_eq!(answer.get(), Some(&42));Structs§
- Ippatsu
- One immutable value initialized at most once successfully.
- Offer
- Result of offering an already-created value.
- Shot
- Borrowed result of lazy one-shot initialization.
Enums§
- Shot
Status - Whether a call published the value or observed an existing value.