Struct TakeOr

Source
pub struct TakeOr<'a, T, U, N = ()> { /* private fields */ }
Available on crate features arrayvec or alloc only.

Implementations§

Source§

impl<'a, T, U, N> TakeOr<'a, T, U, N>
where T: MaybeEmpty,

Source

pub fn none(self) -> Option<U>

Source§

impl<'a, T, M, const N: usize> TakeOr<'a, ArrayVec<T, N>, T, M>
where [T; N]: Array1,

Source

pub fn get_only(self) -> Result<T, &'a T>

Available on crate feature arrayvec only.
Source

pub fn replace_only(self, replacement: T) -> Result<T, T>

Available on crate feature arrayvec only.
Source

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>
where [T; N]: Array1,

Source

pub fn get(self) -> Result<T, &'a T>

Available on crate feature arrayvec only.
Source

pub fn replace(self, replacement: T) -> Result<T, T>

Available on crate feature arrayvec only.
Source

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>
where [T; N]: Array1,

Source

pub fn get(self) -> Option<Result<T, &'a T>>

Available on crate feature arrayvec only.
Source

pub fn replace(self, replacement: T) -> Option<Result<T, T>>

Available on crate feature arrayvec only.
Source

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,

Source

pub fn get_only(self) -> Result<U, OnlyEntry<'a, K, V>>

Available on crate feature alloc only.
Source

pub fn replace_only(self, value: V) -> Result<U, V>

Available on crate feature alloc only.
Source

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>
where K: Borrow<Q> + Ord, Q: Ord + ?Sized,

Source

pub fn get(self) -> Option<Result<U, OnlyEntry<'a, K, V>>>

Available on crate feature alloc only.
Source

pub fn replace(self, value: V) -> Option<Result<U, V>>

Available on crate feature alloc only.
Source

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, T, U, N> TakeOr<'a, BTreeSet<T>, U, N>
where T: Ord,

Source

pub fn get_only(self) -> Result<U, &'a T>

Available on crate feature alloc only.
Source§

impl<'a, T, Q> TakeOr<'a, BTreeSet<T>, bool, &Q>
where T: Borrow<Q> + Ord, Q: Ord + ?Sized,

Source

pub fn get(self) -> Result<bool, Option<&'a T>>

Available on crate feature alloc only.
Source§

impl<'a, T, Q> TakeOr<'a, BTreeSet<T>, Option<T>, &Q>
where T: Borrow<Q> + Ord, Q: Ord + ?Sized,

Source

pub fn get(self) -> Option<Result<T, &'a T>>

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,

Source

pub fn get_only(self) -> Result<U, IndexedOnlyEntry<'a, K, V>>

Available on crate feature indexmap only.
Source

pub fn replace_only(self, value: V) -> Result<U, V>

Available on crate feature indexmap only.
Source

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>
where S: BuildHasher, Q: Equivalent<K> + Hash + ?Sized,

Source

pub fn get(self) -> Option<Result<U, OnlyEntry<'a, K, V>>>

Available on crate feature indexmap only.
Source

pub fn replace(self, value: V) -> Option<Result<U, V>>

Available on crate feature indexmap only.
Source

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, T, S, U, N> TakeOr<'a, IndexSet<T, S>, U, N>

Source

pub fn get_only(self) -> Result<U, &'a T>

Available on crate feature indexmap only.
Source§

impl<'a, T, S> TakeOr<'a, IndexSet<T, S>, Option<T>, usize>
where S: BuildHasher,

Source

pub fn get(self) -> Option<Result<T, &'a T>>

Available on crate feature indexmap only.
Source§

impl<'a, T, S, Q> TakeOr<'a, IndexSet<T, S>, bool, &Q>
where T: Borrow<Q>, S: BuildHasher, Q: Equivalent<T> + Hash + ?Sized,

Source

pub fn get(self) -> Result<bool, Option<&'a T>>

Available on crate feature indexmap only.
Source§

impl<'a, T, S, Q> TakeOr<'a, IndexSet<T, S>, Option<T>, &Q>
where T: Borrow<Q>, S: BuildHasher, Q: Equivalent<T> + Hash + ?Sized,

Source

pub fn get(self) -> Option<Result<T, &'a T>>

Available on crate feature indexmap only.
Source§

impl<'a, A, T, N> TakeOr<'a, SmallVec<A>, T, N>
where A: Array<Item = T>,

Source

pub fn get_only(self) -> Result<T, &'a T>

Available on crate feature smallvec only.
Source

pub fn replace_only(self, replacement: T) -> Result<T, T>

Available on crate feature smallvec only.
Source

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>,

Source

pub fn get(self) -> Result<T, &'a T>

Available on crate feature smallvec only.
Source

pub fn replace(self, replacement: T) -> Result<T, T>

Available on crate feature smallvec only.
Source

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>

Source

pub fn get_only(self) -> Result<char, char>

Available on crate feature alloc only.
Source

pub fn replace_only(self, replacement: char) -> Result<char, char>

Available on crate feature alloc only.
Source

pub fn else_replace_only<F>(self, f: F) -> Result<char, char>
where F: FnOnce() -> char,

Available on crate feature alloc only.
Source§

impl TakeOr<'_, String, char, usize>

Source

pub fn get(self) -> Result<char, char>

Available on crate feature alloc only.
Source

pub fn replace(self, replacement: char) -> Result<char, char>

Available on crate feature alloc only.
Source

pub fn else_replace<F>(self, f: F) -> Result<char, char>
where F: FnOnce() -> char,

Available on crate feature alloc only.
Source§

impl<'a, T, N> TakeOr<'a, Vec<T>, T, N>

Source

pub fn get_only(self) -> Result<T, &'a T>

Available on crate feature alloc only.
Source

pub fn replace_only(self, replacement: T) -> Result<T, T>

Available on crate feature alloc only.
Source

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, Vec<T>, T, usize>

Source

pub fn get(self) -> Result<T, &'a T>

Available on crate feature alloc only.
Source

pub fn replace(self, replacement: T) -> Result<T, T>

Available on crate feature alloc only.
Source

pub fn else_replace<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>

Source

pub fn get_only(self) -> Result<T, &'a T>

Available on crate feature alloc only.
Source

pub fn replace_only(self, replacement: T) -> Result<T, T>

Available on crate feature alloc only.
Source

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>

Source

pub fn get(self) -> Option<Result<T, &'a T>>

Available on crate feature alloc only.
Source

pub fn replace(self, replacement: T) -> Option<Result<T, T>>

Available on crate feature alloc only.
Source

pub fn else_replace<F>(self, f: F) -> Option<Result<T, T>>
where F: FnOnce() -> T,

Available on crate feature alloc only.

Trait Implementations§

Source§

impl<T, U, N> Debug for TakeOr<'_, T, U, N>
where NonEmpty<T>: Debug, N: Debug,

Source§

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

Formats the value using the given formatter. Read more

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>

§

impl<'a, T, U, N> Send for TakeOr<'a, T, U, N>
where N: Send, T: Send,

§

impl<'a, T, U, N> Sync for TakeOr<'a, T, U, N>
where N: Sync, T: Sync,

§

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> 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> IntoEither for T

Source§

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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

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
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
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.