Skip to content

Commit 9562c01

Browse files
committed
add safety comments
1 parent f92241d commit 9562c01

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

library/std/src/io/util.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,12 +131,14 @@ impl Read for Repeat {
131131
}
132132

133133
fn read_buf(&mut self, buf: &mut ReadBuf<'_>) -> io::Result<()> {
134+
// SAFETY: No uninit bytes are being written
134135
for slot in unsafe { buf.unfilled_mut() } {
135136
slot.write(self.byte);
136137
}
137138

138139
let remaining = buf.remaining();
139140

141+
// SAFETY: the entire unfilled portion of buf has been initialized
140142
unsafe {
141143
buf.assume_init(remaining);
142144
}

0 commit comments

Comments
 (0)