3 unstable releases

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

#187 in Memory management

Download history 262/week @ 2024-11-15 403/week @ 2024-11-22 312/week @ 2024-11-29 402/week @ 2024-12-06 333/week @ 2024-12-13 231/week @ 2024-12-20 59/week @ 2024-12-27 309/week @ 2025-01-03 366/week @ 2025-01-10 395/week @ 2025-01-17 590/week @ 2025-01-24 1322/week @ 2025-01-31 583/week @ 2025-02-07 922/week @ 2025-02-14 1142/week @ 2025-02-21 764/week @ 2025-02-28

3,695 downloads per month
Used in 11 crates (5 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