Enum ezomyte::Quasi
[−]
[src]
#[must_use]pub enum Quasi<T, S = Json> { True(T), Substitute(S), }
Quasi-equivalent wrapper over a deserialized type.
Basically, Quasi<T> is simply wrapping T in the vast majority of cases.
The only exception is when T couldn't be deserialized successfully,
in which case the original source/subsititute representation (S)
is made available.
Because Quasi<T> is essentially T, you'd normally just call the get method
and work with the resulting &T reference directly.
Alternatively, the wrapper itself offers an Option-like interface for
safely accessing T.
There is intentionally no equivalent interface to access the subsititute value
outside of pattern matching.
Variants
True(T)The usual, "true" value.
Substitute(S)The substitute, "fake", undeserialized value.
Methods
impl<T, S> Quasi<T, S>[src]
pub fn expect(self, msg: &str) -> T[src]
Unwraps the container, yielding the underlying value.
Panics
Panics if it's a Substitute with a custom panic message provided by msg.
ⓘImportant traits for &'a mut Wpub fn get(&self) -> &T[src]
ⓘImportant traits for &'a mut Wpub fn get_mut(&mut self) -> &mut T[src]
pub fn unwrap(self) -> T[src]
impl<T, S> Quasi<T, S>[src]
pub fn as_ref(&self) -> Option<&T>[src]
Returns an optional reference to the underlying value.
pub fn as_mut(&mut self) -> Option<&mut T>[src]
Returns an optional mutable reference to the underlying value.
ⓘImportant traits for Box<W>pub fn iter<'q>(&'q self) -> Box<Iterator<Item = &'q T> + 'q>[src]
Returns an iterator over the one underlying value.
ⓘImportant traits for Box<W>pub fn iter_mut<'q>(&'q mut self) -> Box<Iterator<Item = &'q mut T> + 'q>[src]
Returns a mutable iterator over the one underlying value.
pub fn unwrap_or(self, def: T) -> T[src]
Returns the underlying value or a default.
pub fn unwrap_or_else<F: FnOnce() -> T>(self, f: F) -> T[src]
Returns the underlying value or computes one from a closure.
impl<T: Default, S> Quasi<T, S>[src]
pub fn unwrap_or_default(self) -> T[src]
Returns the underlying value or a default.
impl<T, S> Quasi<T, S>[src]
pub fn map<U, F: FnOnce(T) -> U>(self, f: F) -> Quasi<U, S>[src]
Maps a Quasi<T> to Quasi<U> by applying a function to the underlying value.
Trait Implementations
impl<T, S> From<T> for Quasi<T, S>[src]
impl<T: Default, S> Default for Quasi<T, S>[src]
impl<'de, T, S> Deserialize<'de> for Quasi<T, S> where
T: Deserialize<'de>,
S: Clone + Deserialize<'de> + IntoDeserializer<'de>, [src]
T: Deserialize<'de>,
S: Clone + Deserialize<'de> + IntoDeserializer<'de>,
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where
D: Deserializer<'de>, [src]
D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
impl<T: FromStr> FromStr for Quasi<T, String>[src]
type Err = NoError
The associated error which can be returned from parsing.
fn from_str(s: &str) -> Result<Self, Self::Err>[src]
Parses a string s to return a value of this type. Read more
impl<T, S> Serialize for Quasi<T, S> where
T: Serialize,
S: Serialize, [src]
T: Serialize,
S: Serialize,
fn serialize<Ser>(&self, serializer: Ser) -> Result<Ser::Ok, Ser::Error> where
Ser: Serializer, [src]
Ser: Serializer,
Serialize this value into the given Serde serializer. Read more
impl<T, S> Clone for Quasi<T, S> where
T: Clone,
S: Clone, [src]
T: Clone,
S: Clone,
fn clone(&self) -> Self[src]
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)1.0.0[src]
Performs copy-assignment from source. Read more
impl<T, S> PartialEq for Quasi<T, S> where
T: PartialEq,
S: PartialEq, [src]
T: PartialEq,
S: PartialEq,
fn eq(&self, other: &Self) -> bool[src]
This method tests for self and other values to be equal, and is used by ==. Read more
fn ne(&self, other: &Rhs) -> bool1.0.0[src]
This method tests for !=.
impl<T, S> PartialOrd for Quasi<T, S> where
T: PartialOrd,
S: PartialOrd, [src]
T: PartialOrd,
S: PartialOrd,
fn partial_cmp(&self, other: &Self) -> Option<Ordering>[src]
This method returns an ordering between self and other values if one exists. Read more
fn lt(&self, other: &Rhs) -> bool1.0.0[src]
This method tests less than (for self and other) and is used by the < operator. Read more
fn le(&self, other: &Rhs) -> bool1.0.0[src]
This method tests less than or equal to (for self and other) and is used by the <= operator. Read more
fn gt(&self, other: &Rhs) -> bool1.0.0[src]
This method tests greater than (for self and other) and is used by the > operator. Read more
fn ge(&self, other: &Rhs) -> bool1.0.0[src]
This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more
impl<T, S> Into<Option<T>> for Quasi<T, S>[src]
impl<T, S> Into<Result<T, S>> for Quasi<T, S>[src]
impl<T, S> Debug for Quasi<T, S> where
T: Debug,
S: Debug, [src]
T: Debug,
S: Debug,
fn fmt(&self, fmt: &mut Formatter) -> Result[src]
Formats the value using the given formatter. Read more
impl<T, S> Display for Quasi<T, S> where
T: Display,
S: Display, [src]
T: Display,
S: Display,