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<'a> PrecomputeSize for Nullable<&'a Container>
impl<'a> PrecomputeSize for Nullable<&'a Container>
Source§impl<'a> PrecomputeSize for Nullable<&'a Id>
impl<'a> PrecomputeSize for Nullable<&'a Id>
Source§impl<'a> PrecomputeSize for Nullable<&'a IriRef>
impl<'a> PrecomputeSize for Nullable<&'a IriRef>
Source§impl<'a> PrecomputeSize for Nullable<&'a LenientLangTagBuf>
impl<'a> PrecomputeSize for Nullable<&'a LenientLangTagBuf>
Source§impl<'a> PrecomputeSize for Nullable<&'a TermDefinition>
impl<'a> PrecomputeSize for Nullable<&'a TermDefinition>
Source§impl<'a> PrecomputeSize for Nullable<&'a Type>
impl<'a> PrecomputeSize for Nullable<&'a Type>
Source§impl<'a> PrecomputeSize for Nullable<&'a Vocab>
impl<'a> PrecomputeSize for Nullable<&'a 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<'a> Print for Nullable<&'a Id>
impl<'a> Print for Nullable<&'a 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<'a> Print for Nullable<&'a IriRef>
impl<'a> Print for Nullable<&'a 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<'a> Print for Nullable<&'a LenientLangTagBuf>
impl<'a> Print for Nullable<&'a 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<'a> Print for Nullable<&'a Type>
impl<'a> Print for Nullable<&'a 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<'a> Print for Nullable<&'a Vocab>
impl<'a> Print for Nullable<&'a 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<'a> PrintWithSize for Nullable<&'a Container>
impl<'a> PrintWithSize for Nullable<&'a Container>
Source§impl<'a> PrintWithSize for Nullable<&'a TermDefinition>
impl<'a> PrintWithSize for Nullable<&'a 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.Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
fn equivalent(&self, key: &K) -> bool
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T, U, C> IntoWithContext<U, C> for Twhere
U: FromWithContext<T, C>,
impl<T, U, C> IntoWithContext<U, C> for Twhere
U: FromWithContext<T, C>,
Source§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
Source§impl<T> ToStringFallible for Twhere
T: Display,
impl<T> ToStringFallible for Twhere
T: Display,
Source§fn try_to_string(&self) -> Result<String, TryReserveError>
fn try_to_string(&self) -> Result<String, TryReserveError>
ToString::to_string
, but without panic on OOM.