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 as Deref>::Target>where
T: Deref,
pub fn as_deref(&self) -> Nullable<&<T as Deref>::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<Nullable<T>>, <D as Deserializer<'de>>::Error>where
T: Deserialize<'de>,
D: Deserializer<'de>,
Available on crate feature serde only.
pub fn optional<'de, D>(
deserializer: D,
) -> Result<Option<Nullable<T>>, <D as Deserializer<'de>>::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 for Nullable<T>where
T: Copy,
Source§impl<'de, T> Deserialize<'de> for Nullable<T>where
T: Deserialize<'de>,
Available on crate feature serde only.
impl<'de, T> Deserialize<'de> for Nullable<T>where
T: Deserialize<'de>,
serde only.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>,
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>,
impl<T> Eq for Nullable<T>where
T: Eq,
Source§impl<T> Ord for Nullable<T>where
T: Ord,
impl<T> Ord for Nullable<T>where
T: Ord,
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 for Nullable<T>where
T: PartialOrd,
impl<T> PartialOrd for Nullable<T>where
T: PartialOrd,
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<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<(), Error>
fn fmt_with( &self, f: &mut Formatter<'_>, options: &Options, indent: usize, ) -> Result<(), Error>
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<(), Error>
fn fmt_with( &self, f: &mut Formatter<'_>, options: &Options, indent: usize, ) -> Result<(), Error>
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<(), Error>
fn fmt_with( &self, f: &mut Formatter<'_>, options: &Options, indent: usize, ) -> Result<(), Error>
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<&IriRef<String>>
impl Print for Nullable<&IriRef<String>>
Source§fn fmt_with(
&self,
f: &mut Formatter<'_>,
_options: &Options,
_indent: usize,
) -> Result<(), Error>
fn fmt_with( &self, f: &mut Formatter<'_>, _options: &Options, _indent: usize, ) -> Result<(), Error>
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<IriRef<String>>
impl Print for Nullable<IriRef<String>>
Source§fn fmt_with(
&self,
f: &mut Formatter<'_>,
_options: &Options,
_indent: usize,
) -> Result<(), Error>
fn fmt_with( &self, f: &mut Formatter<'_>, _options: &Options, _indent: usize, ) -> Result<(), Error>
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<(), Error>
fn fmt_with( &self, f: &mut Formatter<'_>, options: &Options, indent: usize, ) -> Result<(), Error>
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<(), Error>
fn fmt_with( &self, f: &mut Formatter<'_>, _options: &Options, _indent: usize, ) -> Result<(), Error>
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<(), Error>
fn fmt_with( &self, f: &mut Formatter<'_>, _options: &Options, _indent: usize, ) -> Result<(), Error>
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>
Source§impl<T> Serialize for Nullable<T>where
T: Serialize,
Available on crate feature serde only.
impl<T> Serialize for Nullable<T>where
T: Serialize,
serde only.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,
impl<T> StructuralPartialEq for Nullable<T>where
T: PartialEq,
Source§impl<T> TryFromJson for Nullable<T>where
T: TryFromJson,
impl<T> TryFromJson for Nullable<T>where
T: TryFromJson,
Source§type Error = <T as TryFromJson>::Error
type Error = <T as TryFromJson>::Error
Self.Source§fn try_from_json(
value: &Value,
) -> Result<Nullable<T>, <Nullable<T> as TryFromJson>::Error>
fn try_from_json( value: &Value, ) -> Result<Nullable<T>, <Nullable<T> as TryFromJson>::Error>
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> 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,
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