♐ rt_ref

Crates.io docs.rs CI Coverage Status

Ref types with internal mutability that implement Send and Sync.

These types are shared by [rt_map] and [rt_vec].

Usage

Add the following to Cargo.toml:

toml rt_ref = "0.1.1"

In code:

```rust use rt_ref::{Cell, Ref, RefMut};

let a = 1;

// Insert a value into a collection, wrapped with Cell. let mut v = Vec::new(); v.push(Cell::new(a));

let v = v; // v is now compile-time immutable. let a = v.get(0).map(|cell| RefMut::new(cell.borrow_mut())); a.map(|mut a| { *a += 2; });

let a = v.get(0).map(|cell| Ref::new(cell.borrow())); assert_eq!(Some(3), a.map(|a| *a)); ```

License

Licensed under either of

at your option.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.