pub struct BailoutGuard<T> { /* private fields */ }Expand description
A guard that drops its value even if a PHP bailout skips its frame.
BailoutGuard::new moves the value to the heap and registers a cleanup entry with
the innermost try_catch frame. If that frame catches a
bailout, it drops the value. If you drop the guard, the guard releases the entry and
drops the value.
§Performance
BailoutGuard::new makes one heap allocation. Use it only for values that must be
released: file handles, network connections, locks. Do not wrap simple values.
Implementations§
Source§impl<T: 'static> BailoutGuard<T>
impl<T: 'static> BailoutGuard<T>
Sourcepub fn new(value: T) -> Self
pub fn new(value: T) -> Self
Wraps value in a new guard.
The value moves to the heap. The guard registers a cleanup entry with the
innermost try_catch frame.
Sourcepub fn into_inner(self) -> T
pub fn into_inner(self) -> T
Consumes the guard and returns the value.
The guard releases its cleanup entry.
Trait Implementations§
Source§impl<T> Deref for BailoutGuard<T>
impl<T> Deref for BailoutGuard<T>
Source§impl<T> DerefMut for BailoutGuard<T>
impl<T> DerefMut for BailoutGuard<T>
Source§impl<T> Drop for BailoutGuard<T>
impl<T> Drop for BailoutGuard<T>
Auto Trait Implementations§
impl<T> !Send for BailoutGuard<T>
impl<T> !Sync for BailoutGuard<T>
impl<T> Freeze for BailoutGuard<T>
impl<T> RefUnwindSafe for BailoutGuard<T>where
*mut T: RefUnwindSafe,
impl<T> Unpin for BailoutGuard<T>
impl<T> UnsafeUnpin for BailoutGuard<T>where
*mut T: UnsafeUnpin,
impl<T> UnwindSafe for BailoutGuard<T>where
*mut 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