Crates.io | bo_cell |
lib.rs | bo_cell |
version | 0.1.0 |
source | src |
created_at | 2019-09-07 05:14:23.172708 |
updated_at | 2019-09-07 05:14:23.172708 |
description | A RefCell which borrows its contents rather than owning them |
homepage | |
repository | https://github.com/bradymcd/BoCell-rs.git |
max_upload_size | |
id | 162915 |
size | 10,075 |
This is a simple Rust crate which implements a borrowing Cell variant.
In some cases where the internal mutability and reference properties of a RefCell is required it is
advantageous to coerce that Cell from a reference on a temporary basis rather than storing the data as
contained in a RefCell and constantly contending with the runtime borrow-checking RefCells employ.
BoCell is a RefCell which borrows its contents from a &mut
while in scope. This allows for
non-overlapping mutable borrows to be taken simultaneously from behind a single &mut
.
This is a one track crate. BoCell
can be created from a &mut
and may be mutably borrowed from
once at a time as a RefMut
.
RefMut
implement both Deref
traits and so can be used like any other reference in terms of
method calls. RefMut
can also be manipulated by it's associated functions RefMut::map()
subreferences, RefMut::split_tuple()
, and RefMut::split_triple()
split the reference into 2 and 3
parts. Be mindful when splitting RefMut
s, having two overlapping mutable borrows active at once is
undefined behaviour.