Struct winsafe::guard::DeleteObjectGuard
source · pub struct DeleteObjectGuard<T>where
T: GdiObject,{ /* private fields */ }
Available on crate features
kernel
and gdi
only.Expand description
RAII implementation for a GdiObject
which
automatically calls
DeleteObject
when the object goes out of scope.
Implementations§
source§impl<T> DeleteObjectGuard<T>where
T: GdiObject,
impl<T> DeleteObjectGuard<T>where
T: GdiObject,
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
DeleteObject
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 DeleteObjectGuard<T>where
T: GdiObject,
impl<T> Deref for DeleteObjectGuard<T>where
T: GdiObject,
source§impl<T> DerefMut for DeleteObjectGuard<T>where
T: GdiObject,
impl<T> DerefMut for DeleteObjectGuard<T>where
T: GdiObject,
Auto Trait Implementations§
impl<T> Freeze for DeleteObjectGuard<T>where
T: Freeze,
impl<T> RefUnwindSafe for DeleteObjectGuard<T>where
T: RefUnwindSafe,
impl<T> Send for DeleteObjectGuard<T>
impl<T> Sync for DeleteObjectGuard<T>where
T: Sync,
impl<T> Unpin for DeleteObjectGuard<T>where
T: Unpin,
impl<T> UnwindSafe for DeleteObjectGuard<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