#arc #owned #smart-pointers

ownref

Provide the smart pointer type that bundles the data with its owner

4 releases (2 breaking)

0.3.1 Jan 9, 2022
0.3.0 Jan 9, 2022
0.2.0 Jan 9, 2022
0.1.0 Jan 8, 2022

#2364 in Rust patterns

Download history 4/week @ 2023-06-07 3/week @ 2023-06-14 17/week @ 2023-06-21 43/week @ 2023-06-28 33/week @ 2023-07-05 16/week @ 2023-07-12 34/week @ 2023-07-19 21/week @ 2023-07-26 11/week @ 2023-08-02 23/week @ 2023-08-09 29/week @ 2023-08-16 17/week @ 2023-08-23 10/week @ 2023-08-30 37/week @ 2023-09-06 16/week @ 2023-09-13 8/week @ 2023-09-20

71 downloads per month
Used in 5 crates (via nuscenes-data)

MIT license

57KB
1.5K SLoC

ownref

[ doc | crates.io ]

This crate provides the smart pointer type that bundles the data with its owner. It has the folloing features:

  • The data is either a reference to a portion of the owner, or a data type that may contain references to the owner.
  • The refernce can be ordered by data content or data pointer address.
  • The owner is contained in Box or Arc.

The following table shows Box-based reference types. The generic O denotes the owner type and I denotes the data type.

data type (I) \ ordering Content ordered Pointer address ordered
Reference BoxRefC<O, I> BoxRefA<O, I>
Owned BoxOwnedC<O, I> BoxOwnedA<O, I>

The following table shows Arc-based reference types.

data type (I) \ ordering Content ordered Pointer address ordered
Reference ArcRefC<O, I> ArcRefA<O, I>
Owned ArcOwnedC<O, I> ArcOwnedA<O, I>

For example,

  • BoxRefA<Vec<str>, str> is a reference to str within the owner Vec<str>, which is ordered by pointer address.
  • ArcOwnedC<Vec<str>, Option<&str>> stores the data type Option<&str>, which contains a reference within the owner Vec<str>. The reference is ordered by the data content.

License

MIT license. See license file.

No runtime deps