BorrowSwapResult

Enum BorrowSwapResult 

Source
pub enum BorrowSwapResult<'a, T: Sync + Send + 'static, E: Sync + Send + 'static> {
    BorrowSwapped(BorrowGuard<'a, T>),
    CellWasEmpty(E),
}
Expand description

Result enum to indicate the outcomes of a borrow_swap operation.

Variants§

§

BorrowSwapped(BorrowGuard<'a, T>)

Borrow swap succeeded and the returned guard should be used.

§

CellWasEmpty(E)

Cell was empty when the borrow swap operation was performed

Implementations§

Source§

impl<'a, T: Sync + Send + 'static, E: Sync + Send + 'static> BorrowSwapResult<'a, T, E>

Source

pub fn unwrap(self) -> BorrowGuard<'a, T>

Unwraps the borrow guard

§Panics

if CellWasEmpty

Source

pub const fn is_ok(&self) -> bool

Source

pub const fn is_err(&self) -> bool

Source

pub fn unwrap_err(self) -> E

Unwraps the value intended as replacement as result of a failed operation.

§Panics

if BorrowSwapped

Source

pub fn map_err<X: Sync + Send + 'static>( self, f: impl FnOnce(E) -> X, ) -> BorrowSwapResult<'a, T, X>

Maps the type in the CellWasEmpty case. Does nothing for BorrowSwapped.

Source

pub fn into_result(self) -> Result<BorrowGuard<'a, T>, E>

Transforms this into a core::Result type.

§Errors

In case of CellWasEmpty

Trait Implementations§

Source§

impl<T: Sync + Send + Debug + 'static, E: Sync + Send + Debug + 'static> Debug for BorrowSwapResult<'_, T, E>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'a, T: Sync + Send + 'static, E: Sync + Send + 'static> From<BorrowSwapResult<'a, T, E>> for Result<BorrowGuard<'a, T>, E>

Source§

fn from(value: BorrowSwapResult<'a, T, E>) -> Self

Converts to this type from the input type.

Auto Trait Implementations§

§

impl<'a, T, E> Freeze for BorrowSwapResult<'a, T, E>
where E: Freeze,

§

impl<'a, T, E> RefUnwindSafe for BorrowSwapResult<'a, T, E>

§

impl<'a, T, E> Send for BorrowSwapResult<'a, T, E>

§

impl<'a, T, E> Sync for BorrowSwapResult<'a, T, E>

§

impl<'a, T, E> Unpin for BorrowSwapResult<'a, T, E>
where E: Unpin,

§

impl<'a, T, E> UnwindSafe for BorrowSwapResult<'a, T, E>
where E: UnwindSafe, T: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.