sled
sled copied to clipboard
Prevent UB with `assume_init` on uninit bytes
If size_of::<F>
< size_of::<Data>
, the remaining bytes would be uninitialised - thus, calling assume_init
would cause UB, as noted by Miri. Storing the data as MaybeUninit
and casting to the correct FnOnce()
object before reading it fixes this, only using initialized bytes.