Hacker News new | ask | show | jobs
by Zagitta 512 days ago
Maybe Rust needs another type of reference that's exclusive write only? Right now there's RO (&T) and exclusive RW (&mut T) but WO is missing.

Having a WO reference would allow these read_buf APIs to express they only write and never read so the uninitialized memory is safe to pass directly.

2 comments

In some sense that's exactly what a `&mut MaybeUninit<T>` is?
Probably more once https://doc.rust-lang.org/beta/std/mem/union.MaybeUninit.htm... is no longer nightly-only.
everyone just tell you to use mpsr in this case