3 unstable releases

0.2.0 Jan 30, 2022
0.1.1 Oct 9, 2018
0.1.0 Oct 9, 2018

#193 in Memory management

Download history 523/week @ 2024-01-11 394/week @ 2024-01-18 778/week @ 2024-01-25 1118/week @ 2024-02-01 1042/week @ 2024-02-08 452/week @ 2024-02-15 447/week @ 2024-02-22 377/week @ 2024-02-29 695/week @ 2024-03-07 554/week @ 2024-03-14 890/week @ 2024-03-21 671/week @ 2024-03-28 628/week @ 2024-04-04 1064/week @ 2024-04-11 787/week @ 2024-04-18 774/week @ 2024-04-25

3,353 downloads per month
Used in 6 crates (4 directly)

MIT license

11KB
112 lines

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.

License

Licensed under MIT license.

lib.rs:

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.

No runtime deps