4 stable releases

1.2.0 Mar 16, 2022
1.1.1 May 13, 2020
1.1.0 May 9, 2020
1.0.0 Jan 31, 2020

#518 in Rust patterns

Download history 2731/week @ 2024-07-21 2965/week @ 2024-07-28 2579/week @ 2024-08-04 3489/week @ 2024-08-11 2868/week @ 2024-08-18 3904/week @ 2024-08-25 3567/week @ 2024-09-01 3277/week @ 2024-09-08 3067/week @ 2024-09-15 5038/week @ 2024-09-22 3477/week @ 2024-09-29 2606/week @ 2024-10-06 2871/week @ 2024-10-13 3204/week @ 2024-10-20 2763/week @ 2024-10-27 2607/week @ 2024-11-03

11,691 downloads per month
Used in 54 crates (3 directly)

MIT/Apache

68KB
1K SLoC

Known unique versions of Rc and Arc. This allows them to be used for mutable ownership.

The main reason to use RcBox or ArcBox is for types that will be reference counted, but need some "fixing up" done after being allocated behind the reference counted pointer. With the standard library types, you would use get_mut and have to handle the impossible case where the value was shared. With the known unique versions, you have DerefMut, so it's as simple as mutating behind a Box.

  • erasable: Erase pointers of their concrete type.
  • ptr-union: Pointer unions the size of a pointer.
  • rc-borrow: Borrowed forms of Rc and Arc.
  • slice-dst: Support for custom slice-based DSTs.

Why not triomphe?

Triomphe is a great atomic reference counting library! The main difference between triomphe and these utilities is that triomphe implements a new Arc type that doesn't support weak references (and as such does not have to pay the cost of handling potential weak references), whereas these pointer utilities use the standard library's reference counting types. If you need to work with standard library Arc/Rc, triomphe won't work for you.

If you want a more battle-tested library by the servo developers, use triomphe. If you want small, self-contained extensions to the standard library types, use these pointer utilities.

Additionally, triomphe only supports atomic reference counting. We provide support for both Arc and Rc.

Minimum Supported Rust Version

We require a minimum Rust version of 1.41.0. This is for an adjustment of local trait impl checking.

Minimum version support is only guaranteed with minimal version resolution (-Z minimal-versions/--minimal-versions) due to how dependencies are handled. The minimum version of Rust will only be incremented with minor version bumps, not patch version bumps, and will be deliberate and clearly noted in change notes.

License

Licensed under either of

at your option.

If you are a highly paid worker at any company that prioritises profit over people, you can still use this crate. I simply wish you will unionise and push back against the obsession for growth, control, and power that is rampant in your workplace. Please take a stand against the horrible working conditions they inflict on your lesser paid colleagues, and more generally their disrespect for the very human rights they claim to fight for.

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.

Dependencies

~25KB