Closed a1phyr closed 1 week ago
Nice catch! It doesn't seem to annoy MIRI though: https://play.rust-lang.org/?edition=2021&gist=3ffc5bffdb51903f2613413470953084
released in bytemuck-1.20
I think the old version filled padding with zeroes, but the new one isn't guaranteed to.
write_bytes is similar to C’s memset, but sets count * size_of::
() bytes to val.
https://doc.rust-lang.org/core/ptr/fn.write_bytes.html
and the size of T includes any tail padding
so i think this is the same?
Looks like these are deliberately two lines to prevent the length check (using
&self
) from invalidating the mut pointer.