surelock 0.1.0

Deadlock-free locks for Rust with compile time guarantees, incremental locks, and atomic lock sets.
Documentation
//! Attempting to acquire a lower level after a higher level should
//! not compile.

use surelock::{key::lock_scope, level::Level, mutex::Mutex};

type High = Level<5>;
type Low = Level<2>;

fn main() {
    let high: Mutex<u32, High> = Mutex::new(1);
    let low: Mutex<u32, Low> = Mutex::new(2);

    lock_scope(|key| {
        // Lock high first (Level<5>)
        let (_, key) = key.lock(&high);

        // Try to lock low (Level<2>) -- should fail:
        // Level<2> does not implement LockAfter<Level<5>>
        let (_, _key) = key.lock(&low);
    });
}