Skip to content

Commit

Permalink
Update global_static example
Browse files Browse the repository at this point in the history
  • Loading branch information
agerasev committed Jan 11, 2025
1 parent 4e1506a commit 0579d48
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
10 changes: 5 additions & 5 deletions examples/global_static.rs
Original file line number Diff line number Diff line change
@@ -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::<i32, 1> = StaticRb::default();
}
static RB: OnceMut<StaticRb<i32, 1>> = 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));
Expand Down

0 comments on commit 0579d48

Please sign in to comment.