Reason safety for unsafe blocks for uwp stdin
This commit is contained in:
parent
a8ac6d471e
commit
4e01157969
1 changed files with 2 additions and 0 deletions
|
@ -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)
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue