You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
As discussed long ago, and recently in #138, it is undefined behaviour
to create or transmute to `&[u8]` when the underlying data is possibly
uninit. This also holds true for transmuting arbitrary `T: Copy`
structures to `&[u8]` where eventual padding bytes are considered
uninitialized, hence invalid for `u8`.
Instead of coming up with a massive safety API that distinguishes
between uninitialized and initialized buffers - which turn out to be
really easy to invalidate by copying structures with padding bytes -
place the onus on the user to keep track of initialization status by
only ever providing mapped slices in an `unsafe` context. Users are
expected to initialize the buffer using `ptr::copy(_nonoverlapping)()`
when used from a CPU context instead of calling `.mapped_mut_slice()`,
or switch to the new [presser] API from #138.
[presser]: https://crates.io/crates/presser
0 commit comments