Struct winsafe::guard::CloseHandleGuard
source · pub struct CloseHandleGuard<T>where
T: Handle,{ /* private fields */ }
Available on crate feature
kernel
only.Expand description
RAII implementation for a Handle
which
automatically calls
CloseHandle
when the object goes out of scope.
Implementations§
source§impl<T> CloseHandleGuard<T>where
T: Handle,
impl<T> CloseHandleGuard<T>where
T: Handle,
sourcepub const unsafe fn new(handle: T) -> Self
pub const unsafe fn new(handle: T) -> Self
Constructs the guard by taking ownership of the handle.
§Safety
Be sure the handle must be freed with
CloseHandle
at the end of scope.
sourcepub fn leak(&mut self) -> T
pub fn leak(&mut self) -> T
Ejects the underlying handle, leaving a
Handle::INVALID
in its place.
Since the internal handle will be invalidated, the destructor will not run. It’s your responsability to run it, otherwise you’ll cause a resource leak.
Trait Implementations§
source§impl<T> Deref for CloseHandleGuard<T>where
T: Handle,
impl<T> Deref for CloseHandleGuard<T>where
T: Handle,
source§impl<T> DerefMut for CloseHandleGuard<T>where
T: Handle,
impl<T> DerefMut for CloseHandleGuard<T>where
T: Handle,
Auto Trait Implementations§
impl<T> RefUnwindSafe for CloseHandleGuard<T>where
T: RefUnwindSafe,
impl<T> Send for CloseHandleGuard<T>
impl<T> Sync for CloseHandleGuard<T>where
T: Sync,
impl<T> Unpin for CloseHandleGuard<T>where
T: Unpin,
impl<T> UnwindSafe for CloseHandleGuard<T>where
T: UnwindSafe,
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more