no_mutex

Crates.iono_mutex
lib.rsno_mutex
version0.0.1
sourcesrc
created_at2020-05-01 16:37:08.500058
updated_at2020-05-02 18:19:05.943889
descriptionA lean no_std mutex for single threaded environments
homepage
repositoryhttps://github.com/richardanaya/no_mutex
max_upload_size
id236287
size14,490
RICHΛRD ΛNΛYΛ (richardanaya)

documentation

README

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);
}
Commit count: 7

cargo fmt