pub enum Nullable<T> {
Null,
Some(T),
}Expand description
Value that can be null.
The Option type is used in this crate to indicate values that
may or may not be defined.
Sometimes however,
value can be explicitly defined as null,
hence the need for this type.
Variants§
Implementations§
Source§impl<T> Nullable<T>
impl<T> Nullable<T>
pub fn as_deref(&self) -> Nullable<&<T as Deref>::Target>where
T: Deref,
Sourcepub fn map<F, U>(self, f: F) -> Nullable<U>where
F: FnOnce(T) -> U,
pub fn map<F, U>(self, f: F) -> Nullable<U>where
F: FnOnce(T) -> U,
Map the inner value using the given function.
pub fn cast<U>(self) -> Nullable<U>where
T: Into<U>,
pub fn unwrap_or(self, default: T) -> T
pub fn unwrap_or_default(self) -> Twhere
T: Default,
Source§impl<T> Nullable<T>
impl<T> Nullable<T>
pub fn optional<'de, D>(
deserializer: D,
) -> Result<Option<Nullable<T>>, <D as Deserializer<'de>>::Error>where
T: Deserialize<'de>,
D: Deserializer<'de>,
Trait Implementations§
Source§impl<'de, T> Deserialize<'de> for Nullable<T>where
T: Deserialize<'de>,
impl<'de, T> Deserialize<'de> for Nullable<T>where
T: Deserialize<'de>,
Source§fn deserialize<D>(
deserializer: D,
) -> Result<Nullable<T>, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
fn deserialize<D>(
deserializer: D,
) -> Result<Nullable<T>, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl<T, V> DisplayWithContext<V> for Nullable<T>where
T: DisplayWithContext<V>,
impl<T, V> DisplayWithContext<V> for Nullable<T>where
T: DisplayWithContext<V>,
Source§impl<T> Ord for Nullable<T>where
T: Ord,
impl<T> Ord for Nullable<T>where
T: Ord,
1.21.0 · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the maximum of two values. Read more
Source§impl<T> PartialOrd for Nullable<T>where
T: PartialOrd,
impl<T> PartialOrd for Nullable<T>where
T: PartialOrd,
Source§impl PrecomputeSize for Nullable<&Container>
impl PrecomputeSize for Nullable<&Container>
Source§impl PrecomputeSize for Nullable<&Id>
impl PrecomputeSize for Nullable<&Id>
Source§impl PrecomputeSize for Nullable<&IriRef>
impl PrecomputeSize for Nullable<&IriRef>
Source§impl PrecomputeSize for Nullable<&LenientLangTagBuf>
impl PrecomputeSize for Nullable<&LenientLangTagBuf>
Source§impl PrecomputeSize for Nullable<&TermDefinition>
impl PrecomputeSize for Nullable<&TermDefinition>
Source§impl PrecomputeSize for Nullable<&Type>
impl PrecomputeSize for Nullable<&Type>
Source§impl PrecomputeSize for Nullable<&Vocab>
impl PrecomputeSize for Nullable<&Vocab>
Source§impl PrecomputeSize for Nullable<Direction>
impl PrecomputeSize for Nullable<Direction>
Source§impl PrecomputeSize for Nullable<IriRefBuf>
impl PrecomputeSize for Nullable<IriRefBuf>
Source§impl PrecomputeSize for Nullable<bool>
impl PrecomputeSize for Nullable<bool>
Source§impl Print for Nullable<&Id>
impl Print for Nullable<&Id>
fn fmt_with( &self, f: &mut Formatter<'_>, options: &Options, indent: usize, ) -> Result<(), Error>
Source§fn pretty_print(&self) -> Printed<'_, Self>
fn pretty_print(&self) -> Printed<'_, Self>
Print the value with
Options::pretty options.Source§fn compact_print(&self) -> Printed<'_, Self>
fn compact_print(&self) -> Printed<'_, Self>
Print the value with
Options::compact options.Source§fn inline_print(&self) -> Printed<'_, Self>
fn inline_print(&self) -> Printed<'_, Self>
Print the value with
Options::inline options.Source§fn print_with(&self, options: Options) -> Printed<'_, Self>
fn print_with(&self, options: Options) -> Printed<'_, Self>
Print the value with the given options.
Source§impl Print for Nullable<&IriRef>
impl Print for Nullable<&IriRef>
fn fmt_with( &self, f: &mut Formatter<'_>, _options: &Options, _indent: usize, ) -> Result<(), Error>
Source§fn pretty_print(&self) -> Printed<'_, Self>
fn pretty_print(&self) -> Printed<'_, Self>
Print the value with
Options::pretty options.Source§fn compact_print(&self) -> Printed<'_, Self>
fn compact_print(&self) -> Printed<'_, Self>
Print the value with
Options::compact options.Source§fn inline_print(&self) -> Printed<'_, Self>
fn inline_print(&self) -> Printed<'_, Self>
Print the value with
Options::inline options.Source§fn print_with(&self, options: Options) -> Printed<'_, Self>
fn print_with(&self, options: Options) -> Printed<'_, Self>
Print the value with the given options.
Source§impl Print for Nullable<&LenientLangTagBuf>
impl Print for Nullable<&LenientLangTagBuf>
fn fmt_with( &self, f: &mut Formatter<'_>, _options: &Options, _indent: usize, ) -> Result<(), Error>
Source§fn pretty_print(&self) -> Printed<'_, Self>
fn pretty_print(&self) -> Printed<'_, Self>
Print the value with
Options::pretty options.Source§fn compact_print(&self) -> Printed<'_, Self>
fn compact_print(&self) -> Printed<'_, Self>
Print the value with
Options::compact options.Source§fn inline_print(&self) -> Printed<'_, Self>
fn inline_print(&self) -> Printed<'_, Self>
Print the value with
Options::inline options.Source§fn print_with(&self, options: Options) -> Printed<'_, Self>
fn print_with(&self, options: Options) -> Printed<'_, Self>
Print the value with the given options.
Source§impl Print for Nullable<&Type>
impl Print for Nullable<&Type>
fn fmt_with( &self, f: &mut Formatter<'_>, options: &Options, indent: usize, ) -> Result<(), Error>
Source§fn pretty_print(&self) -> Printed<'_, Self>
fn pretty_print(&self) -> Printed<'_, Self>
Print the value with
Options::pretty options.Source§fn compact_print(&self) -> Printed<'_, Self>
fn compact_print(&self) -> Printed<'_, Self>
Print the value with
Options::compact options.Source§fn inline_print(&self) -> Printed<'_, Self>
fn inline_print(&self) -> Printed<'_, Self>
Print the value with
Options::inline options.Source§fn print_with(&self, options: Options) -> Printed<'_, Self>
fn print_with(&self, options: Options) -> Printed<'_, Self>
Print the value with the given options.
Source§impl Print for Nullable<&Vocab>
impl Print for Nullable<&Vocab>
fn fmt_with( &self, f: &mut Formatter<'_>, options: &Options, indent: usize, ) -> Result<(), Error>
Source§fn pretty_print(&self) -> Printed<'_, Self>
fn pretty_print(&self) -> Printed<'_, Self>
Print the value with
Options::pretty options.Source§fn compact_print(&self) -> Printed<'_, Self>
fn compact_print(&self) -> Printed<'_, Self>
Print the value with
Options::compact options.Source§fn inline_print(&self) -> Printed<'_, Self>
fn inline_print(&self) -> Printed<'_, Self>
Print the value with
Options::inline options.Source§fn print_with(&self, options: Options) -> Printed<'_, Self>
fn print_with(&self, options: Options) -> Printed<'_, Self>
Print the value with the given options.
Source§impl Print for Nullable<Direction>
impl Print for Nullable<Direction>
fn fmt_with( &self, f: &mut Formatter<'_>, _options: &Options, _indent: usize, ) -> Result<(), Error>
Source§fn pretty_print(&self) -> Printed<'_, Self>
fn pretty_print(&self) -> Printed<'_, Self>
Print the value with
Options::pretty options.Source§fn compact_print(&self) -> Printed<'_, Self>
fn compact_print(&self) -> Printed<'_, Self>
Print the value with
Options::compact options.Source§fn inline_print(&self) -> Printed<'_, Self>
fn inline_print(&self) -> Printed<'_, Self>
Print the value with
Options::inline options.Source§fn print_with(&self, options: Options) -> Printed<'_, Self>
fn print_with(&self, options: Options) -> Printed<'_, Self>
Print the value with the given options.
Source§impl Print for Nullable<IriRefBuf>
impl Print for Nullable<IriRefBuf>
fn fmt_with( &self, f: &mut Formatter<'_>, _options: &Options, _indent: usize, ) -> Result<(), Error>
Source§fn pretty_print(&self) -> Printed<'_, Self>
fn pretty_print(&self) -> Printed<'_, Self>
Print the value with
Options::pretty options.Source§fn compact_print(&self) -> Printed<'_, Self>
fn compact_print(&self) -> Printed<'_, Self>
Print the value with
Options::compact options.Source§fn inline_print(&self) -> Printed<'_, Self>
fn inline_print(&self) -> Printed<'_, Self>
Print the value with
Options::inline options.Source§fn print_with(&self, options: Options) -> Printed<'_, Self>
fn print_with(&self, options: Options) -> Printed<'_, Self>
Print the value with the given options.
Source§impl Print for Nullable<bool>
impl Print for Nullable<bool>
fn fmt_with( &self, f: &mut Formatter<'_>, options: &Options, indent: usize, ) -> Result<(), Error>
Source§fn pretty_print(&self) -> Printed<'_, Self>
fn pretty_print(&self) -> Printed<'_, Self>
Print the value with
Options::pretty options.Source§fn compact_print(&self) -> Printed<'_, Self>
fn compact_print(&self) -> Printed<'_, Self>
Print the value with
Options::compact options.Source§fn inline_print(&self) -> Printed<'_, Self>
fn inline_print(&self) -> Printed<'_, Self>
Print the value with
Options::inline options.Source§fn print_with(&self, options: Options) -> Printed<'_, Self>
fn print_with(&self, options: Options) -> Printed<'_, Self>
Print the value with the given options.
Source§impl PrintWithSize for Nullable<&Container>
impl PrintWithSize for Nullable<&Container>
Source§impl PrintWithSize for Nullable<&TermDefinition>
impl PrintWithSize for Nullable<&TermDefinition>
Source§impl<T> Serialize for Nullable<T>where
T: Serialize,
impl<T> Serialize for Nullable<T>where
T: Serialize,
Source§fn serialize<S>(
&self,
serializer: S,
) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>where
S: Serializer,
fn serialize<S>(
&self,
serializer: S,
) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>where
S: Serializer,
Serialize this value into the given Serde serializer. Read more
Source§impl<T> TryFromJson for Nullable<T>where
T: TryFromJson,
impl<T> TryFromJson for Nullable<T>where
T: TryFromJson,
type Error = <T as TryFromJson>::Error
fn try_from_json( value: Value, ) -> Result<Nullable<T>, <Nullable<T> as TryFromJson>::Error>
impl<T> Copy for Nullable<T>where
T: Copy,
impl<T> Eq for Nullable<T>where
T: Eq,
impl<T> StructuralPartialEq for Nullable<T>
Auto Trait Implementations§
impl<T> Freeze for Nullable<T>where
T: Freeze,
impl<T> RefUnwindSafe for Nullable<T>where
T: RefUnwindSafe,
impl<T> Send for Nullable<T>where
T: Send,
impl<T> Sync for Nullable<T>where
T: Sync,
impl<T> Unpin for Nullable<T>where
T: Unpin,
impl<T> UnwindSafe for Nullable<T>where
T: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> BorrowUnordered for T
impl<T> BorrowUnordered for T
fn as_unordered(&self) -> &Unordered<T>
Source§impl<T> CallHasher for T
impl<T> CallHasher for T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.