Crates.io | pin-cell |
lib.rs | pin-cell |
version | 0.2.0 |
source | src |
created_at | 2018-10-09 15:38:37.745426 |
updated_at | 2022-01-30 12:04:38.602637 |
description | A pin-safe cell |
homepage | |
repository | https://github.com/dignifiedquire/pin-cell |
max_upload_size | |
id | 88890 |
size | 11,910 |
PinCell
This library defines the PinCell
type, a pinning variant of the standard
library's RefCell
.
It is not safe to "pin project" through a RefCell
- getting a pinned
reference to something inside the RefCell
when you have a pinned
refernece to the RefCell
- because RefCell
is too powerful.
A PinCell
is slightly less powerful than RefCell
: unlike a RefCell
,
one cannot get a mutable reference into a PinCell
, only a pinned mutable
reference (Pin<&mut T>
). This makes pin projection safe, allowing you
to use interior mutability with the knowledge that T
will never actually
be moved out of the RefCell
that wraps it.