diff --git a/Cargo.toml b/Cargo.toml index 47f51e7..e1f3763 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -36,7 +36,7 @@ crossbeam-utils = { version = "0.8", default-features = false } portable-atomic = { version = "1", default-features = false, optional = true } [dev-dependencies] -once_mut = "0.1.0" +lock-free-static = "0.2.1" [[example]] name = "simple" diff --git a/examples/global_static.rs b/examples/global_static.rs index 99c4e9a..ed072f4 100644 --- a/examples/global_static.rs +++ b/examples/global_static.rs @@ -1,14 +1,14 @@ #![no_std] -use once_mut::once_mut; +use lock_free_static::OnceMut; use ringbuf::{traits::*, StaticRb}; -once_mut! { - static mut RB: StaticRb:: = StaticRb::default(); -} +static RB: OnceMut> = OnceMut::new(); fn main() { - let (mut prod, mut cons) = RB.take().unwrap().split_ref(); + RB.set(StaticRb::default()).ok().expect("RB already initialized"); + + let (mut prod, mut cons) = RB.get_mut().expect("Mutable reference to RB already taken").split_ref(); assert_eq!(prod.try_push(123), Ok(())); assert_eq!(prod.try_push(321), Err(321));