https://github.com/rustyyato/out-ref
https://github.com/rustyyato/out-ref
Last synced: about 1 year ago
JSON representation
- Host: GitHub
- URL: https://github.com/rustyyato/out-ref
- Owner: RustyYato
- Created: 2019-01-09T19:56:46.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2021-01-20T15:29:20.000Z (over 5 years ago)
- Last Synced: 2025-01-30T16:58:07.490Z (over 1 year ago)
- Language: Rust
- Size: 5.86 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
Awesome Lists containing this project
README
# out-reference
This crate brings out references to Rust, this crate has `no_std` support
Out reference *never* read values behind the reference
```rust
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
```rust
use out_reference::*;
let mut x = vec![0, 1, 2];
let mut out_x: Out<'_, Vec> = x.out();
out_x.set(vec![]);
assert_eq!(x, vec![]);
```