Skip to content

Commit 4e01157

Browse files
committed
Reason safety for unsafe blocks for uwp stdin
1 parent a8ac6d4 commit 4e01157

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

Diff for: library/std/src/sys/windows/stdio_uwp.rs

+2
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ pub fn get_handle(handle_id: c::DWORD) -> io::Result<c::HANDLE> {
2626

2727
fn write(handle_id: c::DWORD, data: &[u8]) -> io::Result<usize> {
2828
let handle = get_handle(handle_id)?;
29+
// SAFETY: The handle returned from `get_handle` must be valid and non-null.
2930
let handle = unsafe { Handle::from_raw_handle(handle) };
3031
ManuallyDrop::new(handle).write(data)
3132
}
@@ -39,6 +40,7 @@ impl Stdin {
3940
impl io::Read for Stdin {
4041
fn read(&mut self, buf: &mut [u8]) -> io::Result<usize> {
4142
let handle = get_handle(c::STD_INPUT_HANDLE)?;
43+
// SAFETY: The handle returned from `get_handle` must be valid and non-null.
4244
let handle = unsafe { Handle::from_raw_handle(handle) };
4345
ManuallyDrop::new(handle).read(buf)
4446
}

0 commit comments

Comments
 (0)