#mutex #derive

macro flexible-locks_derive

Custom Derive for Flexible Locks

1 unstable release

Uses old Rust 2015

0.1.0 Apr 28, 2018

#72 in #mutex

22 downloads per month
Used in flexible-locks


115 lines

Custom Derive for Flexible Locks

This crate provides custom derives for traits describing types that can be wrapped in Flexible Locks types.

For now, Flexible Locks only provides a Mutex type, so this crate provides a #[derive(MutexProtected)].

The #[mutex] attribute is used to indicate the data field containing the raw mutex type.


extern crate flexible_locks;
extern crate flexible_locks_derive;
use flexible_locks::{Mutex, RawMutex};

// Pick your choice of raw mutex;
use flexible_locks::CRITICAL_SECTION as RawOsMutex;
use flexible_locks::pthread_mutex_t as RawOsMutex;

struct Data {
    a: usize,
    mutex: RawOsMutex,
    b: usize,


~44K SLoC