pub enum Nullable<T> {
Null,
Some(T),
}Expand description
Value that can be null.
Option is used throughout this crate for entries that may or may not be
present. A JSON-LD entry can also be present with the explicit value
null, which is meaningful: it unsets whatever the surrounding context
inherited. Hence this separate type, so that Option<Nullable<T>> can tell
an absent entry from an entry set to null.
Variants§
Implementations§
Source§impl<T> Nullable<T>
impl<T> Nullable<T>
Sourcepub fn try_unwrap(self) -> Result<T, NullError>
pub fn try_unwrap(self) -> Result<T, NullError>
Sourcepub fn as_deref(&self) -> Nullable<&T::Target>where
T: Deref,
pub fn as_deref(&self) -> Nullable<&T::Target>where
T: Deref,
Converts &Nullable<T> into Nullable<&T::Target> by dereferencing
the inner value.
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,
Maps the inner value with the given function, keeping null as null.
Sourcepub fn cast<U>(self) -> Nullable<U>where
T: Into<U>,
pub fn cast<U>(self) -> Nullable<U>where
T: Into<U>,
Converts the contained value, keeping null as null.
Sourcepub fn unwrap_or_default(self) -> Twhere
T: Default,
pub fn unwrap_or_default(self) -> Twhere
T: Default,
Returns the contained value, or the default one if it is null.
Source§impl<T> Nullable<T>
impl<T> Nullable<T>
Sourcepub fn optional<'de, D>(deserializer: D) -> Result<Option<Self>, D::Error>where
T: Deserialize<'de>,
D: Deserializer<'de>,
Available on crate feature serde only.
pub fn optional<'de, D>(deserializer: D) -> Result<Option<Self>, D::Error>where
T: Deserialize<'de>,
D: Deserializer<'de>,
serde only.Deserializes a Nullable<T> and wraps it in Some.
Meant as the deserialize_with of an Option<Nullable<T>> field that
also carries #[serde(default)]: an absent entry then yields None,
while an entry present with the value null yields
Some(Nullable::Null). Serde’s own handling of Option would collapse
both cases to None.
§Errors
Returns the deserializer’s error when the value is neither absent, null, nor a valid T.
Trait Implementations§
impl<T: Copy> Copy for Nullable<T>
Source§impl<'de, T: Deserialize<'de>> Deserialize<'de> for Nullable<T>
Available on crate feature serde only.
impl<'de, T: Deserialize<'de>> Deserialize<'de> for Nullable<T>
serde only.Source§fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
Source§impl<T: DisplayWithContext<V>, V> DisplayWithContext<V> for Nullable<T>
impl<T: DisplayWithContext<V>, V> DisplayWithContext<V> for Nullable<T>
impl<T: Eq> Eq for Nullable<T>
Source§impl<'a> From<Nullable<&'a TermDefinition>> for ExpandedRef<'a>
impl<'a> From<Nullable<&'a TermDefinition>> for ExpandedRef<'a>
Source§fn from(value: Nullable<&'a TermDefinition>) -> Self
fn from(value: Nullable<&'a TermDefinition>) -> Self
Source§impl<T: Ord> Ord for Nullable<T>
impl<T: Ord> Ord for Nullable<T>
1.21.0 (const: unstable) · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
1.21.0 (const: unstable) · Source§fn min(self, other: Self) -> Selfwhere
Self: Sized,
fn min(self, other: Self) -> Selfwhere
Self: Sized,
Source§impl<T: PartialOrd> PartialOrd for Nullable<T>
impl<T: PartialOrd> PartialOrd for Nullable<T>
Source§impl PrecomputeSize for Nullable<&Vocab>
impl PrecomputeSize for Nullable<&Vocab>
Source§impl PrecomputeSize for Nullable<&TermDefinition>
impl PrecomputeSize for Nullable<&TermDefinition>
Source§impl PrecomputeSize for Nullable<&Id>
impl PrecomputeSize for Nullable<&Id>
Source§impl PrecomputeSize for Nullable<&Type>
impl PrecomputeSize for Nullable<&Type>
Source§impl PrecomputeSize for Nullable<&Container>
impl PrecomputeSize for Nullable<&Container>
Source§impl PrecomputeSize for Nullable<&IriRefBuf>
impl PrecomputeSize for Nullable<&IriRefBuf>
Source§impl PrecomputeSize for Nullable<IriRefBuf>
impl PrecomputeSize for Nullable<IriRefBuf>
Source§impl PrecomputeSize for Nullable<bool>
impl PrecomputeSize for Nullable<bool>
Source§impl PrecomputeSize for Nullable<&LenientLangTagBuf>
impl PrecomputeSize for Nullable<&LenientLangTagBuf>
Source§impl PrecomputeSize for Nullable<Direction>
impl PrecomputeSize for Nullable<Direction>
Source§impl Print for Nullable<&Vocab>
impl Print for Nullable<&Vocab>
Source§fn fmt_with(
&self,
f: &mut Formatter<'_>,
options: &Options,
indent: usize,
) -> Result
fn fmt_with( &self, f: &mut Formatter<'_>, options: &Options, indent: usize, ) -> Result
f with the given options, starting at the given
indentation level. Read moreSource§fn pretty_print(&self) -> Printed<'_, Self>
fn pretty_print(&self) -> Printed<'_, Self>
Options::pretty options.Source§fn compact_print(&self) -> Printed<'_, Self>
fn compact_print(&self) -> Printed<'_, Self>
Options::compact options.Source§fn inline_print(&self) -> Printed<'_, Self>
fn inline_print(&self) -> Printed<'_, Self>
Options::inline options.Source§fn print_with(&self, options: Options) -> Printed<'_, Self>
fn print_with(&self, options: Options) -> Printed<'_, Self>
Source§impl Print for Nullable<&Id>
impl Print for Nullable<&Id>
Source§fn fmt_with(
&self,
f: &mut Formatter<'_>,
options: &Options,
indent: usize,
) -> Result
fn fmt_with( &self, f: &mut Formatter<'_>, options: &Options, indent: usize, ) -> Result
f with the given options, starting at the given
indentation level. Read moreSource§fn pretty_print(&self) -> Printed<'_, Self>
fn pretty_print(&self) -> Printed<'_, Self>
Options::pretty options.Source§fn compact_print(&self) -> Printed<'_, Self>
fn compact_print(&self) -> Printed<'_, Self>
Options::compact options.Source§fn inline_print(&self) -> Printed<'_, Self>
fn inline_print(&self) -> Printed<'_, Self>
Options::inline options.Source§fn print_with(&self, options: Options) -> Printed<'_, Self>
fn print_with(&self, options: Options) -> Printed<'_, Self>
Source§impl Print for Nullable<&Type>
impl Print for Nullable<&Type>
Source§fn fmt_with(
&self,
f: &mut Formatter<'_>,
options: &Options,
indent: usize,
) -> Result
fn fmt_with( &self, f: &mut Formatter<'_>, options: &Options, indent: usize, ) -> Result
f with the given options, starting at the given
indentation level. Read moreSource§fn pretty_print(&self) -> Printed<'_, Self>
fn pretty_print(&self) -> Printed<'_, Self>
Options::pretty options.Source§fn compact_print(&self) -> Printed<'_, Self>
fn compact_print(&self) -> Printed<'_, Self>
Options::compact options.Source§fn inline_print(&self) -> Printed<'_, Self>
fn inline_print(&self) -> Printed<'_, Self>
Options::inline options.Source§fn print_with(&self, options: Options) -> Printed<'_, Self>
fn print_with(&self, options: Options) -> Printed<'_, Self>
Source§impl Print for Nullable<&IriRefBuf>
impl Print for Nullable<&IriRefBuf>
Source§fn fmt_with(
&self,
f: &mut Formatter<'_>,
_options: &Options,
_indent: usize,
) -> Result
fn fmt_with( &self, f: &mut Formatter<'_>, _options: &Options, _indent: usize, ) -> Result
f with the given options, starting at the given
indentation level. Read moreSource§fn pretty_print(&self) -> Printed<'_, Self>
fn pretty_print(&self) -> Printed<'_, Self>
Options::pretty options.Source§fn compact_print(&self) -> Printed<'_, Self>
fn compact_print(&self) -> Printed<'_, Self>
Options::compact options.Source§fn inline_print(&self) -> Printed<'_, Self>
fn inline_print(&self) -> Printed<'_, Self>
Options::inline options.Source§fn print_with(&self, options: Options) -> Printed<'_, Self>
fn print_with(&self, options: Options) -> Printed<'_, Self>
Source§impl Print for Nullable<IriRefBuf>
impl Print for Nullable<IriRefBuf>
Source§fn fmt_with(
&self,
f: &mut Formatter<'_>,
_options: &Options,
_indent: usize,
) -> Result
fn fmt_with( &self, f: &mut Formatter<'_>, _options: &Options, _indent: usize, ) -> Result
f with the given options, starting at the given
indentation level. Read moreSource§fn pretty_print(&self) -> Printed<'_, Self>
fn pretty_print(&self) -> Printed<'_, Self>
Options::pretty options.Source§fn compact_print(&self) -> Printed<'_, Self>
fn compact_print(&self) -> Printed<'_, Self>
Options::compact options.Source§fn inline_print(&self) -> Printed<'_, Self>
fn inline_print(&self) -> Printed<'_, Self>
Options::inline options.Source§fn print_with(&self, options: Options) -> Printed<'_, Self>
fn print_with(&self, options: Options) -> Printed<'_, Self>
Source§impl Print for Nullable<bool>
impl Print for Nullable<bool>
Source§fn fmt_with(
&self,
f: &mut Formatter<'_>,
options: &Options,
indent: usize,
) -> Result
fn fmt_with( &self, f: &mut Formatter<'_>, options: &Options, indent: usize, ) -> Result
f with the given options, starting at the given
indentation level. Read moreSource§fn pretty_print(&self) -> Printed<'_, Self>
fn pretty_print(&self) -> Printed<'_, Self>
Options::pretty options.Source§fn compact_print(&self) -> Printed<'_, Self>
fn compact_print(&self) -> Printed<'_, Self>
Options::compact options.Source§fn inline_print(&self) -> Printed<'_, Self>
fn inline_print(&self) -> Printed<'_, Self>
Options::inline options.Source§fn print_with(&self, options: Options) -> Printed<'_, Self>
fn print_with(&self, options: Options) -> Printed<'_, Self>
Source§impl Print for Nullable<&LenientLangTagBuf>
impl Print for Nullable<&LenientLangTagBuf>
Source§fn fmt_with(
&self,
f: &mut Formatter<'_>,
_options: &Options,
_indent: usize,
) -> Result
fn fmt_with( &self, f: &mut Formatter<'_>, _options: &Options, _indent: usize, ) -> Result
f with the given options, starting at the given
indentation level. Read moreSource§fn pretty_print(&self) -> Printed<'_, Self>
fn pretty_print(&self) -> Printed<'_, Self>
Options::pretty options.Source§fn compact_print(&self) -> Printed<'_, Self>
fn compact_print(&self) -> Printed<'_, Self>
Options::compact options.Source§fn inline_print(&self) -> Printed<'_, Self>
fn inline_print(&self) -> Printed<'_, Self>
Options::inline options.Source§fn print_with(&self, options: Options) -> Printed<'_, Self>
fn print_with(&self, options: Options) -> Printed<'_, Self>
Source§impl Print for Nullable<Direction>
impl Print for Nullable<Direction>
Source§fn fmt_with(
&self,
f: &mut Formatter<'_>,
_options: &Options,
_indent: usize,
) -> Result
fn fmt_with( &self, f: &mut Formatter<'_>, _options: &Options, _indent: usize, ) -> Result
f with the given options, starting at the given
indentation level. Read moreSource§fn pretty_print(&self) -> Printed<'_, Self>
fn pretty_print(&self) -> Printed<'_, Self>
Options::pretty options.Source§fn compact_print(&self) -> Printed<'_, Self>
fn compact_print(&self) -> Printed<'_, Self>
Options::compact options.Source§fn inline_print(&self) -> Printed<'_, Self>
fn inline_print(&self) -> Printed<'_, Self>
Options::inline options.Source§fn print_with(&self, options: Options) -> Printed<'_, Self>
fn print_with(&self, options: Options) -> Printed<'_, Self>
Source§impl PrintWithSize for Nullable<&TermDefinition>
impl PrintWithSize for Nullable<&TermDefinition>
Source§impl PrintWithSize for Nullable<&Container>
impl PrintWithSize for Nullable<&Container>
impl<T: PartialEq> StructuralPartialEq for Nullable<T>
Source§impl<T: TryFromJson> TryFromJson for Nullable<T>
impl<T: TryFromJson> TryFromJson 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> UnsafeUnpin for Nullable<T>where
T: UnsafeUnpin,
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
Source§impl<T> BorrowUnordered for T
impl<T> BorrowUnordered for T
Source§fn as_unordered(&self) -> &Unordered<T>
fn as_unordered(&self) -> &Unordered<T>
Unordered reference.impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
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
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
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
self is equivalent to key.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
key and return true if they are equal.Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
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>,
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
Source§impl<T> ToCompactString for Twhere
T: Display,
impl<T> ToCompactString for Twhere
T: Display,
Source§fn try_to_compact_string(&self) -> Result<CompactString, ToCompactStringError>
fn try_to_compact_string(&self) -> Result<CompactString, ToCompactStringError>
ToCompactString::to_compact_string() Read moreSource§fn to_compact_string(&self) -> CompactString
fn to_compact_string(&self) -> CompactString
CompactString. Read more