[−][src]Struct idcontain::OptionId
An Option
-like container of Id<T>
that takes up no additional space.
Internally, None
is represented as Id::invalid()
. An OptionId<T>
implements conversion to
and from an Option<Id<T>>
, but it also forwards all the methods that Option<T>
does, for
convenience.
Methods
impl<T> OptionId<T>
[src]
pub fn some(id: Id<T>) -> Self
[src]
pub fn none() -> Self
[src]
pub fn into_option(self) -> Option<Id<T>>
[src]
pub fn is_none(&self) -> bool
[src]
pub fn is_some(&self) -> bool
[src]
pub fn as_ref(&self) -> Option<&Id<T>>
[src]
pub fn as_mut(&mut self) -> Option<&mut Id<T>>
[src]
pub fn expect(self, msg: &str) -> Id<T>
[src]
pub fn unwrap(self) -> Id<T>
[src]
pub fn unwrap_or(self, def: Id<T>) -> Id<T>
[src]
pub fn unwrap_or_else<F>(self, f: F) -> Id<T> where
F: FnOnce() -> Id<T>,
[src]
F: FnOnce() -> Id<T>,
pub fn map<U, F>(self, f: F) -> Option<U> where
F: FnOnce(Id<T>) -> U,
[src]
F: FnOnce(Id<T>) -> U,
pub fn map_or<U, F>(self, default: U, f: F) -> U where
F: FnOnce(Id<T>) -> U,
[src]
F: FnOnce(Id<T>) -> U,
pub fn map_or_else<U, D, F>(self, default: D, f: F) -> U where
D: FnOnce() -> U,
F: FnOnce(Id<T>) -> U,
[src]
D: FnOnce() -> U,
F: FnOnce(Id<T>) -> U,
pub fn ok_or<E>(self, err: E) -> Result<Id<T>, E>
[src]
pub fn ok_or_else<E, F>(self, err: F) -> Result<Id<T>, E> where
F: FnOnce() -> E,
[src]
F: FnOnce() -> E,
pub fn iter(&self) -> OptionIntoIter<&Id<T>>
[src]
pub fn iter_mut(&mut self) -> OptionIntoIter<&mut Id<T>>
[src]
pub fn and<U, O>(self, optb: O) -> Option<U> where
O: Into<Option<U>>,
[src]
O: Into<Option<U>>,
pub fn and_then<U, O, F>(self, f: F) -> Option<U> where
F: FnOnce(Id<T>) -> O,
O: Into<Option<U>>,
[src]
F: FnOnce(Id<T>) -> O,
O: Into<Option<U>>,
pub fn or<O>(self, optb: O) -> Option<Id<T>> where
O: Into<Option<Id<T>>>,
[src]
O: Into<Option<Id<T>>>,
pub fn or_else<F, O>(self, f: F) -> Option<Id<T>> where
F: FnOnce() -> O,
O: Into<Option<Id<T>>>,
[src]
F: FnOnce() -> O,
O: Into<Option<Id<T>>>,
pub fn take(&mut self) -> Self
[src]
Trait Implementations
impl<T> Into<Option<Id<T>>> for OptionId<T>
[src]
impl<T> From<Option<Id<T>>> for OptionId<T>
[src]
impl<T> Clone for OptionId<T>
[src]
fn clone(&self) -> Self
[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl<T> Copy for OptionId<T>
[src]
impl<T> Default for OptionId<T>
[src]
impl<T> Eq for OptionId<T>
[src]
impl<T> Ord for OptionId<T>
[src]
fn cmp(&self, other: &Self) -> Ordering
[src]
fn max(self, other: Self) -> Self
1.21.0[src]
fn min(self, other: Self) -> Self
1.21.0[src]
fn clamp(self, min: Self, max: Self) -> Self
[src]
impl<T> PartialEq<OptionId<T>> for OptionId<T>
[src]
impl<T> PartialOrd<OptionId<T>> for OptionId<T>
[src]
fn partial_cmp(&self, other: &Self) -> Option<Ordering>
[src]
#[must_use]
fn lt(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]
fn le(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]
fn gt(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]
fn ge(&self, other: &Rhs) -> bool
1.0.0[src]
impl<T> Debug for OptionId<T>
[src]
impl<T> Hash for OptionId<T>
[src]
Auto Trait Implementations
impl<T> Send for OptionId<T> where
T: Send,
T: Send,
impl<T> Sync for OptionId<T> where
T: Sync,
T: Sync,
impl<T> Unpin for OptionId<T> where
T: Unpin,
T: Unpin,
impl<T> UnwindSafe for OptionId<T> where
T: UnwindSafe,
T: UnwindSafe,
impl<T> RefUnwindSafe for OptionId<T> where
T: RefUnwindSafe,
T: RefUnwindSafe,
Blanket Implementations
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> From<T> for T
[src]
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,