out-reference 0.2.0

out references
Documentation
  • Coverage
  • 100%
    12 out of 12 items documented1 out of 12 items with examples
  • Size
  • Source code size: 6.38 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: 8s Average build duration of successful builds.
  • all releases: 8s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • RustyYato

This crate brings out references to Rust, this crate has no_std support Out reference never read values behind the reference

use out_reference::*;

let mut x = 0;

let mut out_x: Out<'_, u32> = x.out();
out_x.set(10);

assert_eq!(x, 10);

Note that setting a value does not drop the old value, as that would require at least 1 read of the value behind the pointer

So, the code below leaks the vector

use out_reference::*;

let mut x = vec![0, 1, 2];

let mut out_x: Out<'_, Vec<u32>> = x.out();
out_x.set(vec![]);

assert_eq!(x, vec![]);