Enum serde_util::MayBe [−][src]
pub enum MayBe<T> {
Is(T),
IsNot,
}
Expand description
Something that may be of the kind of T
.
If a value doesn’t have the kind of T
, this will discard the value and
provide an MayBe::IsNot
. Nevertheless, if the value does have the kind of
T
but cannot be deserialized by T
, this will also fail to deserialize,
making this wrapper “shallow”.
For example, struct
s have the same kind as a JSON object, {}
, If the
contents of said JSON object don’t match what the struct
is expecting,
like if the struct Foo { bar: u32 }
is being matched, as MayBe<Foo>
,
against {"bar": ""}
, then that is an error. However, matching the same
MayBe<Foo>
against a JSON array, []
would not lead to an error, but
to an MayBe::IsNot
.
Can only be used with self-describing formats, like JSON.
Variants
Implementations
Converts this &mut MayBe<T>
into an Option<&mut T>
.
Trait Implementations
Deserialize this value from the given Serde deserializer. Read more
This method returns an ordering between self
and other
values if one exists. Read more
This method tests less than (for self
and other
) and is used by the <
operator. Read more
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
This method tests greater than (for self
and other
) and is used by the >
operator. Read more
Auto Trait Implementations
impl<T> RefUnwindSafe for MayBe<T> where
T: RefUnwindSafe,
impl<T> UnwindSafe for MayBe<T> where
T: UnwindSafe,
Blanket Implementations
Mutably borrows from an owned value. Read more