[−][src]Module rtic_core::prelude
Makes locks work on N-tuples, locks the mutexes from left-to-right in the tuple. These are used to reduce rightward drift in code and to help make intentions clearer.
Example
use mutex_trait::prelude::*; fn normal_lock( a: &mut impl Mutex<T = i32>, b: &mut impl Mutex<T = i32>, c: &mut impl Mutex<T = i32> ) { // A lot of rightward drift... a.lock(|a| { b.lock(|b| { c.lock(|c| { *a += 1; *b += 1; *c += 1; }); }); }); }
Has a shorthand as:
use mutex_trait::prelude::*; fn tuple_lock( a: &mut impl Mutex<T = i32>, b: &mut impl Mutex<T = i32>, c: &mut impl Mutex<T = i32> ) { // Look! Single indent and less to write (a, b, c).lock(|a, b, c| { *a += 1; *b += 1; *c += 1; }); }
Re-exports
pub use crate::Mutex; |
Traits
| TupleExt01 | Auto-generated tuple implementation, see |
| TupleExt02 | Auto-generated tuple implementation, see |
| TupleExt03 | Auto-generated tuple implementation, see |
| TupleExt04 | Auto-generated tuple implementation, see |
| TupleExt05 | Auto-generated tuple implementation, see |
| TupleExt06 | Auto-generated tuple implementation, see |
| TupleExt07 | Auto-generated tuple implementation, see |
| TupleExt08 | Auto-generated tuple implementation, see |
| TupleExt09 | Auto-generated tuple implementation, see |
| TupleExt10 | Auto-generated tuple implementation, see |
| TupleExt11 | Auto-generated tuple implementation, see |
| TupleExt12 | Auto-generated tuple implementation, see |