add safety comments

This commit is contained in:
DrMeepster 2021-06-29 15:13:28 -07:00
parent f92241d251
commit 9562c01879

View File

@ -131,12 +131,14 @@ impl Read for Repeat {
}
fn read_buf(&mut self, buf: &mut ReadBuf<'_>) -> io::Result<()> {
// SAFETY: No uninit bytes are being written
for slot in unsafe { buf.unfilled_mut() } {
slot.write(self.byte);
}
let remaining = buf.remaining();
// SAFETY: the entire unfilled portion of buf has been initialized
unsafe {
buf.assume_init(remaining);
}