[−][src]Enum quantified::Quantified
Variants
Implementations
impl<T> Quantified<T>
[src]
pub fn map<U, F: FnOnce(T) -> U>(self, f: F) -> Quantified<U>
[src]
Maps an Quantified<T>
to Quantified<U>
by applying a function to a contained Some
or Excluding
value.
Examples
Converts an Quantified<
String
>
into an Quantified<
usize
>
, consuming
the original:
let some_string = Quantified::Some(String::from("Hello, World!")); // `Quantified::map` takes self *by value*, consuming `maybe_some_string` let some_len = some_string.map(|s| s.len()); assert_eq!(some_len, Quantified::Some(13));
pub const fn as_ref(&self) -> Quantified<&T>
[src]
Converts from &Quantified<T>
to Quantified<&T>
.
Examples
Converts a Quantified<
String
>
into a Quantified<
usize
>
,
preserving the original.
The map
method takes the self
argument by value, consuming the original,
so this technique uses as_ref
to first take a Quantified
to a reference
to the value inside the original.
let text: Quantified<String> = Quantified::Some("Hello, world!".to_string()); // First, cast `Quantified<String>` to `Quantified<&String>` with `as_ref`, // then consume *that* with `map`, leaving `text` on the stack. let text_length: Quantified<usize> = text.as_ref().map(|s| s.len()); println!("still can print text: {:?}", text);
pub fn as_mut(&mut self) -> Quantified<&mut T>
[src]
Converts from &mut Quantified<T>
to Quantified<&mut T>
.
Examples
let mut x = Some(2); match x.as_mut() { Some(v) => *v = 42, None => {}, } assert_eq!(x, Some(42));
impl<T: Deref> Quantified<T>
[src]
pub fn as_deref(&self) -> Quantified<&T::Target>
[src]
Converts from Quantified<T>
(or &Quantified<T>
) to Quantified<&T::Target>
.
Leaves the original Quantified
in-place, creating a new one with a reference
to the original one, additionally coercing the contents via [Deref
].
Examples
let x: Quantified<String> = Quantified::Some("hey".to_owned()); assert_eq!(x.as_deref(), Quantified::Some("hey")); let x: Quantified<String> = Quantified::All; assert_eq!(x.as_deref(), Quantified::All);
impl<T: DerefMut> Quantified<T>
[src]
pub fn as_deref_mut(&mut self) -> Quantified<&mut T::Target>
[src]
Converts from Quantified<T>
(or &mut Quantified<T>
) to Quantified<&mut T::Target>
.
Leaves the original Quantified
in-place, creating a new one containing a mutable
reference to the inner type's Deref::Target
type.
Examples
let mut x: Quantified<String> = Quantified::Excluding("hey".to_owned()); assert_eq!(x.as_deref_mut().map(|x| { x.make_ascii_uppercase(); x }), Quantified::Excluding("HEY".to_owned().as_mut_str()));
Trait Implementations
impl<T: Clone> Clone for Quantified<T>
[src]
fn clone(&self) -> Quantified<T>
[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl<T: Debug> Debug for Quantified<T>
[src]
impl<T: Eq> Eq for Quantified<T>
[src]
impl<T: Ord> Ord for Quantified<T>
[src]
fn cmp(&self, other: &Quantified<T>) -> Ordering
[src]
#[must_use]fn max(self, other: Self) -> Self
1.21.0[src]
#[must_use]fn min(self, other: Self) -> Self
1.21.0[src]
#[must_use]fn clamp(self, min: Self, max: Self) -> Self
[src]
impl<T: PartialEq> PartialEq<Quantified<T>> for Quantified<T>
[src]
fn eq(&self, other: &Quantified<T>) -> bool
[src]
fn ne(&self, other: &Quantified<T>) -> bool
[src]
impl<T: PartialOrd> PartialOrd<Quantified<T>> for Quantified<T>
[src]
fn partial_cmp(&self, other: &Quantified<T>) -> Option<Ordering>
[src]
fn lt(&self, other: &Quantified<T>) -> bool
[src]
fn le(&self, other: &Quantified<T>) -> bool
[src]
fn gt(&self, other: &Quantified<T>) -> bool
[src]
fn ge(&self, other: &Quantified<T>) -> bool
[src]
impl<T> StructuralEq for Quantified<T>
[src]
impl<T> StructuralPartialEq for Quantified<T>
[src]
Auto Trait Implementations
impl<T> RefUnwindSafe for Quantified<T> where
T: RefUnwindSafe,
T: RefUnwindSafe,
impl<T> Send for Quantified<T> where
T: Send,
T: Send,
impl<T> Sync for Quantified<T> where
T: Sync,
T: Sync,
impl<T> Unpin for Quantified<T> where
T: Unpin,
T: Unpin,
impl<T> UnwindSafe for Quantified<T> where
T: UnwindSafe,
T: UnwindSafe,
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub 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.
pub 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>,