Cage
Cage<Type> is a reader-writer wrapper lock with a simple and safe API.
Usage
use Cage;
static MUTABLE: = default;
MUTABLE.write; // get a mutable reference
let x = MUTABLE.get; // copy
The Cage type offers a wrapper around RwLock from the standard library with a simplified API.
Performance
Thss type's performance largely dependent on the RwLock implementation.
When to use it
The type is useful in two situations:
- Static mutable variables: synchronizes access
- Interior mutability: enforces borrow checker rules at compile-time