This (WIP) PR objective is to fix the issues spotted by @Kixunil (thanks for telling me!):
Minor: using transmute on fat references makes incorrect assumptions about their layout, so that code could break in a future version of Rust.
Fixed by using slice::from_raw_parts{,_mut} instead.
MAJOR: The API used &mut MaybeUninit<_> as its &out reference type, assuming that it was sound to transmute between &mut T and &mut MaybeUninit<T>, which it is not (see https://github.com/rust-lang/rust/issues/66699)
Fixed by using a custom abstraction over &out references that does not let writing MaybeUninit::uninit() into the pointee.
Added some API features, such as being able to forge a &out T from &mut ManuallyDrop<T> (to offer &out refs even when T : !Copy and could thus have drop glue (although leaking is safe, I take an opinionated stance here that so doing ought to be visible and thus verbose)
This (WIP) PR objective is to fix the issues spotted by @Kixunil (thanks for telling me!):
Minor: using
transmute
on fat references makes incorrect assumptions about their layout, so that code could break in a future version of Rust.slice::from_raw_parts{,_mut}
instead.MAJOR: The API used
&mut MaybeUninit<_>
as its&out
reference type, assuming that it was sound to transmute between&mut T
and&mut MaybeUninit<T>
, which it is not (see https://github.com/rust-lang/rust/issues/66699)&out
references that does not let writingMaybeUninit::uninit()
into the pointee.Added some API features, such as being able to forge a
&out T
from&mut ManuallyDrop<T>
(to offer&out
refs even whenT : !Copy
and could thus have drop glue (although leaking is safe, I take an opinionated stance here that so doing ought to be visible and thus verbose)@HeroicKatora do you wanna review this?
TODO:
[ ] Document new methods
[ ] Add extra helpers to
Out
references