From 9562c01879475a01e3ac5a147bc3724a9b5bd1dc Mon Sep 17 00:00:00 2001 From: DrMeepster <19316085+DrMeepster@users.noreply.github.com> Date: Tue, 29 Jun 2021 15:13:28 -0700 Subject: [PATCH] add safety comments --- library/std/src/io/util.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/library/std/src/io/util.rs b/library/std/src/io/util.rs index 0d4fd5fedf7..c1300cd67c0 100644 --- a/library/std/src/io/util.rs +++ b/library/std/src/io/util.rs @@ -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); }