Crate out_reference

Source
Expand description

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![]);

Structs§

Out
An Out Reference, you can only write to this reference using the set method and reborrow this reference with the borrow method. It isn’t safe to read from an Out pointer.

Traits§

OutMethod
Used to create an Out reference, for all types

Functions§

write
Writes a value to the reference without dropping the old value