mirror of
https://github.com/rust-lang/rust.git
synced 2025-05-08 16:07:43 +00:00
Fix Windows compilation errors.
This commit is contained in:
parent
3b97481387
commit
e102c2a3f2
@ -4,7 +4,6 @@
|
|||||||
|
|
||||||
use super::raw::{AsRawHandle, FromRawHandle, IntoRawHandle, RawHandle};
|
use super::raw::{AsRawHandle, FromRawHandle, IntoRawHandle, RawHandle};
|
||||||
use crate::convert::TryFrom;
|
use crate::convert::TryFrom;
|
||||||
use crate::ffi::c_void;
|
|
||||||
use crate::fmt;
|
use crate::fmt;
|
||||||
use crate::fs;
|
use crate::fs;
|
||||||
use crate::marker::PhantomData;
|
use crate::marker::PhantomData;
|
||||||
@ -133,7 +132,7 @@ impl TryFrom<HandleOrNull> for OwnedHandle {
|
|||||||
#[inline]
|
#[inline]
|
||||||
fn try_from(handle_or_null: HandleOrNull) -> Result<Self, ()> {
|
fn try_from(handle_or_null: HandleOrNull) -> Result<Self, ()> {
|
||||||
let owned_handle = handle_or_null.0;
|
let owned_handle = handle_or_null.0;
|
||||||
if owned_handle.handle.as_ptr().is_null() { Err(()) } else { Ok(owned_handle) }
|
if owned_handle.handle.is_null() { Err(()) } else { Ok(owned_handle) }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -143,32 +142,28 @@ impl TryFrom<HandleOrInvalid> for OwnedHandle {
|
|||||||
#[inline]
|
#[inline]
|
||||||
fn try_from(handle_or_invalid: HandleOrInvalid) -> Result<Self, ()> {
|
fn try_from(handle_or_invalid: HandleOrInvalid) -> Result<Self, ()> {
|
||||||
let owned_handle = handle_or_invalid.0;
|
let owned_handle = handle_or_invalid.0;
|
||||||
if owned_handle.handle.as_ptr() == c::INVALID_HANDLE_VALUE {
|
if owned_handle.handle == c::INVALID_HANDLE_VALUE { Err(()) } else { Ok(owned_handle) }
|
||||||
Err(())
|
|
||||||
} else {
|
|
||||||
Ok(owned_handle)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl AsRawHandle for BorrowedHandle<'_> {
|
impl AsRawHandle for BorrowedHandle<'_> {
|
||||||
#[inline]
|
#[inline]
|
||||||
fn as_raw_handle(&self) -> RawHandle {
|
fn as_raw_handle(&self) -> RawHandle {
|
||||||
self.handle.as_ptr()
|
self.handle
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl AsRawHandle for OwnedHandle {
|
impl AsRawHandle for OwnedHandle {
|
||||||
#[inline]
|
#[inline]
|
||||||
fn as_raw_handle(&self) -> RawHandle {
|
fn as_raw_handle(&self) -> RawHandle {
|
||||||
self.handle.as_ptr()
|
self.handle
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl IntoRawHandle for OwnedHandle {
|
impl IntoRawHandle for OwnedHandle {
|
||||||
#[inline]
|
#[inline]
|
||||||
fn into_raw_handle(self) -> RawHandle {
|
fn into_raw_handle(self) -> RawHandle {
|
||||||
let handle = self.handle.as_ptr();
|
let handle = self.handle;
|
||||||
forget(self);
|
forget(self);
|
||||||
handle
|
handle
|
||||||
}
|
}
|
||||||
@ -244,7 +239,7 @@ impl Drop for OwnedHandle {
|
|||||||
#[inline]
|
#[inline]
|
||||||
fn drop(&mut self) {
|
fn drop(&mut self) {
|
||||||
unsafe {
|
unsafe {
|
||||||
let _ = c::CloseHandle(self.handle.as_ptr());
|
let _ = c::CloseHandle(self.handle);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user