surelock 0.1.0

Deadlock-free locks for Rust with compile time guarantees, incremental locks, and atomic lock sets.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
//! Calling scope() while already inside a scope() should not compile
//! (&mut self prevents nesting via borrow checker).

use surelock::key_handle::KeyHandle;

fn main() {
    let mut handle = KeyHandle::claim();

    handle.scope(|_key1| {
        // handle is &mut borrowed by the outer scope.
        // Calling scope again should fail:
        handle.scope(|_key2| {
            // two independent keys -- deadlock risk
        });
    });
}