pub struct Transitionable<T>(/* private fields */);
Expand description
This type can be used in places where you have an &mut T
but need a T
. It is similar to
Option
but with a more limited API that allows an optimization when the panic strategy is
abort.
Implementations§
Source§impl<T> Transitionable<T>
impl<T> Transitionable<T>
Sourcepub fn into_inner(transitionable: Self) -> T
pub fn into_inner(transitionable: Self) -> T
Deconstructs the Transitionable
back into its held value.
§Panics
Panics if the Transitionable
is poisoned.
Sourcepub fn transition<F: FnOnce(T) -> T>(
transitionable: &mut Self,
f: F,
) -> &mut Self
pub fn transition<F: FnOnce(T) -> T>( transitionable: &mut Self, f: F, ) -> &mut Self
Sourcepub const fn is_poisoned(transitionable: &Self) -> bool
pub const fn is_poisoned(transitionable: &Self) -> bool
A Transitionable
becomes poisoned when a panic occurs inside the function passed to
Transitionable::transition
. To use a Transitionable
in an application that may catch and recover
from panics, you can use this function to determine whether a Transitionable
is poisoned.
If a Transitionable
is poisoned, you will have to replace it by creating a new
Transitionable
.
Trait Implementations§
Source§impl<T: Clone> Clone for Transitionable<T>
impl<T: Clone> Clone for Transitionable<T>
Source§fn clone(&self) -> Transitionable<T>
fn clone(&self) -> Transitionable<T>
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreSource§impl<T: Debug> Debug for Transitionable<T>
impl<T: Debug> Debug for Transitionable<T>
Source§impl<T> Deref for Transitionable<T>
impl<T> Deref for Transitionable<T>
Source§impl<T> DerefMut for Transitionable<T>
impl<T> DerefMut for Transitionable<T>
Source§impl<T> From<T> for Transitionable<T>
impl<T> From<T> for Transitionable<T>
Source§impl<T: Hash> Hash for Transitionable<T>
impl<T: Hash> Hash for Transitionable<T>
Source§impl<T: Ord> Ord for Transitionable<T>
impl<T: Ord> Ord for Transitionable<T>
Source§fn cmp(&self, other: &Transitionable<T>) -> Ordering
fn cmp(&self, other: &Transitionable<T>) -> Ordering
1.21.0 · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the maximum of two values. Read more
Source§impl<T: PartialEq> PartialEq for Transitionable<T>
impl<T: PartialEq> PartialEq for Transitionable<T>
Source§impl<T: PartialOrd> PartialOrd for Transitionable<T>
impl<T: PartialOrd> PartialOrd for Transitionable<T>
impl<T: Copy> Copy for Transitionable<T>
impl<T: Eq> Eq for Transitionable<T>
impl<T> StructuralPartialEq for Transitionable<T>
Auto Trait Implementations§
impl<T> Freeze for Transitionable<T>where
T: Freeze,
impl<T> RefUnwindSafe for Transitionable<T>where
T: RefUnwindSafe,
impl<T> Send for Transitionable<T>where
T: Send,
impl<T> Sync for Transitionable<T>where
T: Sync,
impl<T> Unpin for Transitionable<T>where
T: Unpin,
impl<T> UnwindSafe for Transitionable<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