dybs 0.3.0

An experiment in dynamic single-owner, multiple-borrow smart pointers
Documentation
  • Coverage
  • 100%
    5 out of 5 items documented0 out of 4 items with examples
  • Size
  • Source code size: 10.7 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 394.12 kB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 9s Average build duration of successful builds.
  • all releases: 9s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • Skynoodle/dybs
    3 1 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • Skynoodle

Dybs

An experiment in dynamic single-owner, multiple-borrow smart pointers

Why?

Rust's Borrow Checker usually statically enforces single-owner, multiple-borrow semantics. Standard library smart pointers such as Rc extend this to provide a form of dynamic borrow checking, but they do so in a way that also results in allowing multiple owners while also subtly shifting responsibility for checking the lifetimes.

In the static borrow checker case, accessing a borrowed value (reference) can't fail: lifetimes enforce that the owner must keep the value alive long enough to satisfy any outstanding borrows. In the dynamic case, this is reversed: it becomes the responsibility of the holder of a borrowed value (a weak pointer) to handle the possibility that the underlying value has been invalidated by its owner(s).

Dybs investigates a model closer to a dynamic version of the borrow checker's behaviour: Values retain exactly one owner, which can provide runtime-checked borrows of that value and which takes on responsibility for ensuring the value remains valid for the duration of any borrows. This has the consequence that dropping the owning pointer can fail at runtime if there exist any outstanding borrows.