subrc 0.2.0

A tiny crate that exposes a `Rc` like struct, which can be used to create a reference counted pointer to a subregion of a `Rc`.
Documentation
  • Coverage
  • 60%
    3 out of 5 items documented3 out of 4 items with examples
  • Size
  • Source code size: 6.5 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 1.47 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 10s Average build duration of successful builds.
  • all releases: 10s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • hillin/subrc
    2 0 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • hillin

Subrc

crates.io docs.rs

A tiny crate that exposes a Rc like struct, which can be used to create a reference counted pointer to a subregion (member, or member of member etc.) of a Rc.

Example

struct Foo {
    value: i32,
}

let rc = Rc::new(Foo { value: 42 });
let subrc = Subrc::new(rc.clone(), |foo| &foo.value);
// or 
let subrc = subrc!(rc.value);

// subrc derefs to 42
assert_eq!(*subrc, 42);
// subrc points to rc.value
assert!(std::ptr::eq(&*subrc, &rc.value));