#mutex #single-threaded #environments #lean

nightly no-std no_mutex

A lean no_std mutex for single threaded environments

2 releases

0.0.1 May 2, 2020
0.0.0 May 1, 2020

#12 in #lean

39 downloads per month

MIT/Apache

6KB

no_mutex

** this only works on nightly **

A mutex like construct for single threaded applications.

  • Gives you Sync and Send container
  • Lazily loads the mutex value with Default
  • panics if you lock it twice since deadlocking a single threaded app would be pointless
use no_mutex::Mutex;

static FOO: Mutex<Foo> = Mutex::default();

#[derive(Debug)]
struct Foo {
    i:u32
}

impl Default for Foo {
    fn default() -> Self {
        Foo { i: 42 }
    }
}

fn main() {
    let r = FOO.lock();
    println!("{:?}",r);
}

No runtime deps