diff options
| author | bdbai <bdbaiapp@163.com> | 2021-09-23 07:29:52 +0800 |
|---|---|---|
| committer | bdbai <bdbaiapp@163.com> | 2021-09-23 07:29:52 +0800 |
| commit | 4e01157969eb5726f08fa31a898108654d813fdd (patch) | |
| tree | 8bc19404619aa6931d27a532b562b49841be114c /library/std/src/sys | |
| parent | a8ac6d471e074e15e0ecd44744735503c2eaf1dd (diff) | |
Reason safety for unsafe blocks for uwp stdin
Diffstat (limited to 'library/std/src/sys')
| -rw-r--r-- | library/std/src/sys/windows/stdio_uwp.rs | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/library/std/src/sys/windows/stdio_uwp.rs b/library/std/src/sys/windows/stdio_uwp.rs index 31ffa8c9571..32550f796ec 100644 --- a/library/std/src/sys/windows/stdio_uwp.rs +++ b/library/std/src/sys/windows/stdio_uwp.rs @@ -26,6 +26,7 @@ pub fn get_handle(handle_id: c::DWORD) -> io::Result<c::HANDLE> { fn write(handle_id: c::DWORD, data: &[u8]) -> io::Result<usize> { let handle = get_handle(handle_id)?; + // SAFETY: The handle returned from `get_handle` must be valid and non-null. let handle = unsafe { Handle::from_raw_handle(handle) }; ManuallyDrop::new(handle).write(data) } @@ -39,6 +40,7 @@ impl Stdin { impl io::Read for Stdin { fn read(&mut self, buf: &mut [u8]) -> io::Result<usize> { let handle = get_handle(c::STD_INPUT_HANDLE)?; + // SAFETY: The handle returned from `get_handle` must be valid and non-null. let handle = unsafe { Handle::from_raw_handle(handle) }; ManuallyDrop::new(handle).read(buf) } |
