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,
Trait Implementations§
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, M> IntoJsonMeta<M> for Nullable<T>where
T: IntoJsonMeta<M>,
impl<T, M> IntoJsonMeta<M> for Nullable<T>where
T: IntoJsonMeta<M>,
fn into_json_meta(self, meta: M) -> Meta<Value<M>, M>
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> PartialEq<Nullable<T>> for Nullable<T>where
T: PartialEq<T>,
impl<T> PartialEq<Nullable<T>> for Nullable<T>where
T: PartialEq<T>,
source§impl<T> PartialOrd<Nullable<T>> for Nullable<T>where
T: PartialOrd<T>,
impl<T> PartialOrd<Nullable<T>> for Nullable<T>where
T: PartialOrd<T>,
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for
self
and other
) and is used by the <=
operator. Read moresource§impl<'a, M> PrecomputeSize for Nullable<ContainerRef<'a, M>>
impl<'a, M> PrecomputeSize for Nullable<ContainerRef<'a, M>>
source§impl PrecomputeSize for Nullable<Direction>
impl PrecomputeSize for Nullable<Direction>
source§impl<'a> PrecomputeSize for Nullable<IdRef<'a>>
impl<'a> PrecomputeSize for Nullable<IdRef<'a>>
source§impl<'a> PrecomputeSize for Nullable<IriRef<'a>>
impl<'a> PrecomputeSize for Nullable<IriRef<'a>>
source§impl<'a> PrecomputeSize for Nullable<LenientLanguageTag<'a>>
impl<'a> PrecomputeSize for Nullable<LenientLanguageTag<'a>>
source§impl<'a, M, C> PrecomputeSize for Nullable<TermDefinitionRef<'a, M, C>>where
M: Clone,
C: AnyValue<M> + PrecomputeSize,
impl<'a, M, C> PrecomputeSize for Nullable<TermDefinitionRef<'a, M, C>>where
M: Clone,
C: AnyValue<M> + PrecomputeSize,
source§impl<'a> PrecomputeSize for Nullable<TypeRef<'a>>
impl<'a> PrecomputeSize for Nullable<TypeRef<'a>>
source§impl<'a> PrecomputeSize for Nullable<VocabRef<'a>>
impl<'a> PrecomputeSize for Nullable<VocabRef<'a>>
source§impl PrecomputeSize for Nullable<bool>
impl PrecomputeSize for Nullable<bool>
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<'a> Print for Nullable<IdRef<'a>>
impl<'a> Print for Nullable<IdRef<'a>>
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<IriRef<'a>>
impl<'a> Print for Nullable<IriRef<'a>>
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<LenientLanguageTag<'a>>
impl<'a> Print for Nullable<LenientLanguageTag<'a>>
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<TypeRef<'a>>
impl<'a> Print for Nullable<TypeRef<'a>>
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<VocabRef<'a>>
impl<'a> Print for Nullable<VocabRef<'a>>
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, M> PrintWithSize for Nullable<ContainerRef<'a, M>>
impl<'a, M> PrintWithSize for Nullable<ContainerRef<'a, M>>
source§impl<'a, M, C> PrintWithSize for Nullable<TermDefinitionRef<'a, M, C>>where
M: Clone,
C: AnyValue<M> + PrintWithSize,
impl<'a, M, C> PrintWithSize for Nullable<TermDefinitionRef<'a, M, C>>where
M: Clone,
C: AnyValue<M> + PrintWithSize,
source§impl<T, __T> StrippedPartialEq<Nullable<__T>> for Nullable<T>where
T: StrippedPartialEq<__T>,
impl<T, __T> StrippedPartialEq<Nullable<__T>> for Nullable<T>where
T: StrippedPartialEq<__T>,
fn stripped_eq(&self, other: &Nullable<__T>) -> bool
source§impl<M, T> TryFromJson<M> for Nullable<T>where
T: TryFromStrippedJson<M>,
impl<M, T> TryFromJson<M> for Nullable<T>where
T: TryFromStrippedJson<M>,
type Error = InvalidContext
fn try_from_json(
_: Meta<Value<M>, M>
) -> Result<Meta<Nullable<T>, M>, Meta<InvalidContext, M>>
impl<T> Copy for Nullable<T>where
T: Copy,
impl<T> Eq for Nullable<T>where
T: Eq,
impl<T> StructuralEq for Nullable<T>
impl<T> StructuralPartialEq for Nullable<T>
Auto Trait Implementations§
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<Q, K> Equivalent<K> for Qwhere
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
impl<Q, K> Equivalent<K> for Qwhere
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
fn equivalent(&self, key: &K) -> bool
§impl<Q, K> Equivalent<K> for Qwhere
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
impl<Q, K> Equivalent<K> for Qwhere
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Checks if this value is equivalent to the given key. Read more
source§impl<Q, K> Equivalent<K> for Qwhere
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
impl<Q, K> Equivalent<K> for Qwhere
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key
and return true
if they are equal.