pub struct TakeOr<'a, T, U, N = ()> { /* private fields */ }
Available on crate features
arrayvec
or alloc
only.Implementations§
Source§impl<'a, T, M, const N: usize> TakeOr<'a, ArrayVec<T, N>, T, M>
impl<'a, T, M, const N: usize> TakeOr<'a, ArrayVec<T, N>, T, M>
pub fn get_only(self) -> Result<T, &'a T>
Available on crate feature
arrayvec
only.pub fn replace_only(self, replacement: T) -> Result<T, T>
Available on crate feature
arrayvec
only.pub fn else_replace_only<F>(self, f: F) -> Result<T, T>where
F: FnOnce() -> T,
Available on crate feature
arrayvec
only.Source§impl<'a, T, const N: usize> TakeOr<'a, ArrayVec<T, N>, T, usize>
impl<'a, T, const N: usize> TakeOr<'a, ArrayVec<T, N>, T, usize>
pub fn get(self) -> Result<T, &'a T>
Available on crate feature
arrayvec
only.pub fn replace(self, replacement: T) -> Result<T, T>
Available on crate feature
arrayvec
only.pub fn else_replace<F>(self, f: F) -> Result<T, T>where
F: FnOnce() -> T,
Available on crate feature
arrayvec
only.Source§impl<'a, T, const N: usize> TakeOr<'a, ArrayVec<T, N>, Option<T>, usize>
impl<'a, T, const N: usize> TakeOr<'a, ArrayVec<T, N>, Option<T>, usize>
pub fn get(self) -> Option<Result<T, &'a T>>
Available on crate feature
arrayvec
only.pub fn replace(self, replacement: T) -> Option<Result<T, T>>
Available on crate feature
arrayvec
only.pub fn else_replace<F>(self, f: F) -> Option<Result<T, T>>where
F: FnOnce() -> T,
Available on crate feature
arrayvec
only.Source§impl<'a, K, V, U, N> TakeOr<'a, BTreeMap<K, V>, U, N>where
K: Ord,
impl<'a, K, V, U, N> TakeOr<'a, BTreeMap<K, V>, U, N>where
K: Ord,
pub fn get_only(self) -> Result<U, OnlyEntry<'a, K, V>>
Available on crate feature
alloc
only.pub fn replace_only(self, value: V) -> Result<U, V>
Available on crate feature
alloc
only.pub fn else_replace_only<F>(self, f: F) -> Result<U, V>where
F: FnOnce() -> V,
Available on crate feature
alloc
only.Source§impl<'a, K, V, U, Q> TakeOr<'a, BTreeMap<K, V>, Option<U>, &Q>
impl<'a, K, V, U, Q> TakeOr<'a, BTreeMap<K, V>, Option<U>, &Q>
pub fn get(self) -> Option<Result<U, OnlyEntry<'a, K, V>>>
Available on crate feature
alloc
only.pub fn replace(self, value: V) -> Option<Result<U, V>>
Available on crate feature
alloc
only.pub fn else_replace<F>(self, f: F) -> Option<Result<U, V>>where
F: FnOnce() -> V,
Available on crate feature
alloc
only.Source§impl<'a, K, V, S, U, N> TakeOr<'a, IndexMap<K, V, S>, U, N>where
S: BuildHasher,
impl<'a, K, V, S, U, N> TakeOr<'a, IndexMap<K, V, S>, U, N>where
S: BuildHasher,
pub fn get_only(self) -> Result<U, IndexedOnlyEntry<'a, K, V>>
Available on crate feature
indexmap
only.pub fn replace_only(self, value: V) -> Result<U, V>
Available on crate feature
indexmap
only.pub fn else_replace_only<F>(self, f: F) -> Result<U, V>where
F: FnOnce() -> V,
Available on crate feature
indexmap
only.Source§impl<'a, K, V, S, U, Q> TakeOr<'a, IndexMap<K, V, S>, Option<U>, &Q>
impl<'a, K, V, S, U, Q> TakeOr<'a, IndexMap<K, V, S>, Option<U>, &Q>
pub fn get(self) -> Option<Result<U, OnlyEntry<'a, K, V>>>
Available on crate feature
indexmap
only.pub fn replace(self, value: V) -> Option<Result<U, V>>
Available on crate feature
indexmap
only.pub fn else_replace<F>(self, f: F) -> Option<Result<U, V>>where
F: FnOnce() -> V,
Available on crate feature
indexmap
only.Source§impl<'a, A, T, N> TakeOr<'a, SmallVec<A>, T, N>where
A: Array<Item = T>,
impl<'a, A, T, N> TakeOr<'a, SmallVec<A>, T, N>where
A: Array<Item = T>,
pub fn get_only(self) -> Result<T, &'a T>
Available on crate feature
smallvec
only.pub fn replace_only(self, replacement: T) -> Result<T, T>
Available on crate feature
smallvec
only.pub fn else_replace_only<F>(self, f: F) -> Result<T, T>where
F: FnOnce() -> T,
Available on crate feature
smallvec
only.Source§impl<'a, A, T> TakeOr<'a, SmallVec<A>, T, usize>where
A: Array<Item = T>,
impl<'a, A, T> TakeOr<'a, SmallVec<A>, T, usize>where
A: Array<Item = T>,
pub fn get(self) -> Result<T, &'a T>
Available on crate feature
smallvec
only.pub fn replace(self, replacement: T) -> Result<T, T>
Available on crate feature
smallvec
only.pub fn else_replace<F>(self, f: F) -> Result<T, T>where
F: FnOnce() -> T,
Available on crate feature
smallvec
only.Source§impl<N> TakeOr<'_, String, char, N>
impl<N> TakeOr<'_, String, char, N>
pub fn get_only(self) -> Result<char, char>
Available on crate feature
alloc
only.pub fn replace_only(self, replacement: char) -> Result<char, char>
Available on crate feature
alloc
only.pub fn else_replace_only<F>(self, f: F) -> Result<char, char>
Available on crate feature
alloc
only.Source§impl TakeOr<'_, String, char, usize>
impl TakeOr<'_, String, char, usize>
Source§impl<'a, T, N> TakeOr<'a, Vec<T>, T, N>
impl<'a, T, N> TakeOr<'a, Vec<T>, T, N>
pub fn get_only(self) -> Result<T, &'a T>
Available on crate feature
alloc
only.pub fn replace_only(self, replacement: T) -> Result<T, T>
Available on crate feature
alloc
only.pub fn else_replace_only<F>(self, f: F) -> Result<T, T>where
F: FnOnce() -> T,
Available on crate feature
alloc
only.Source§impl<'a, T, N> TakeOr<'a, VecDeque<T>, T, N>
impl<'a, T, N> TakeOr<'a, VecDeque<T>, T, N>
pub fn get_only(self) -> Result<T, &'a T>
Available on crate feature
alloc
only.pub fn replace_only(self, replacement: T) -> Result<T, T>
Available on crate feature
alloc
only.pub fn else_replace_only<F>(self, f: F) -> Result<T, T>where
F: FnOnce() -> T,
Available on crate feature
alloc
only.Source§impl<'a, T> TakeOr<'a, VecDeque<T>, Option<T>, usize>
impl<'a, T> TakeOr<'a, VecDeque<T>, Option<T>, usize>
pub fn get(self) -> Option<Result<T, &'a T>>
Available on crate feature
alloc
only.pub fn replace(self, replacement: T) -> Option<Result<T, T>>
Available on crate feature
alloc
only.pub fn else_replace<F>(self, f: F) -> Option<Result<T, T>>where
F: FnOnce() -> T,
Available on crate feature
alloc
only.Trait Implementations§
Auto Trait Implementations§
impl<'a, T, U, N> Freeze for TakeOr<'a, T, U, N>where
N: Freeze,
impl<'a, T, U, N> RefUnwindSafe for TakeOr<'a, T, U, N>where
N: RefUnwindSafe,
T: RefUnwindSafe,
impl<'a, T, U, N> Send for TakeOr<'a, T, U, N>
impl<'a, T, U, N> Sync for TakeOr<'a, T, U, N>
impl<'a, T, U, N> Unpin for TakeOr<'a, T, U, N>where
N: Unpin,
impl<'a, T, U, N = ()> !UnwindSafe for TakeOr<'a, T, U, N>
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
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more