]> git.lizzy.rs Git - rust.git/commitdiff
add safety comments
authorDrMeepster <19316085+DrMeepster@users.noreply.github.com>
Tue, 29 Jun 2021 22:13:28 +0000 (15:13 -0700)
committerDrMeepster <19316085+DrMeepster@users.noreply.github.com>
Wed, 3 Nov 2021 05:47:26 +0000 (22:47 -0700)
library/std/src/io/util.rs

index 0d4fd5fedf73404ba20e62df3074d48d69053f8f..c1300cd67c086a0b4788a9106faa27898386d378 100644 (file)
@@ -131,12 +131,14 @@ fn read(&mut self, buf: &mut [u8]) -> io::Result<usize> {
     }
 
     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);
         }