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
Null
Null value.
Some(T)
Some other value.
Implementations
sourceimpl<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
sourceimpl<T, V> DisplayWithContext<V> for Nullable<T>where
T: DisplayWithContext<V>,
impl<T, V> DisplayWithContext<V> for Nullable<T>where
T: DisplayWithContext<V>,
sourceimpl<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>
sourceimpl<T> Ord for Nullable<T>where
T: Ord,
impl<T> Ord for Nullable<T>where
T: Ord,
1.21.0 · sourceconst fn max(self, other: Self) -> Self
const fn max(self, other: Self) -> Self
Compares and returns the maximum of two values. Read more
1.21.0 · sourceconst fn min(self, other: Self) -> Self
const fn min(self, other: Self) -> Self
Compares and returns the minimum of two values. Read more
1.50.0 · sourceconst fn clamp(self, min: Self, max: Self) -> Selfwhere
Self: PartialOrd<Self>,
const fn clamp(self, min: Self, max: Self) -> Selfwhere
Self: PartialOrd<Self>,
Restrict a value to a certain interval. Read more
sourceimpl<T> PartialEq<Nullable<T>> for Nullable<T>where
T: PartialEq<T>,
impl<T> PartialEq<Nullable<T>> for Nullable<T>where
T: PartialEq<T>,
sourceimpl<T> PartialOrd<Nullable<T>> for Nullable<T>where
T: PartialOrd<T>,
impl<T> PartialOrd<Nullable<T>> for Nullable<T>where
T: PartialOrd<T>,
sourcefn partial_cmp(&self, other: &Nullable<T>) -> Option<Ordering>
fn partial_cmp(&self, other: &Nullable<T>) -> Option<Ordering>
1.0.0 · sourceconst fn le(&self, other: &Rhs) -> bool
const 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 moresourceimpl<'a, M> PrecomputeSize for Nullable<ContainerRef<'a, M>>
impl<'a, M> PrecomputeSize for Nullable<ContainerRef<'a, M>>
sourceimpl PrecomputeSize for Nullable<Direction>
impl PrecomputeSize for Nullable<Direction>
sourceimpl<'a> PrecomputeSize for Nullable<IdRef<'a>>
impl<'a> PrecomputeSize for Nullable<IdRef<'a>>
sourceimpl<'a> PrecomputeSize for Nullable<IriRef<'a>>
impl<'a> PrecomputeSize for Nullable<IriRef<'a>>
sourceimpl<'a> PrecomputeSize for Nullable<LenientLanguageTag<'a>>
impl<'a> PrecomputeSize for Nullable<LenientLanguageTag<'a>>
sourceimpl<'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,
sourceimpl<'a> PrecomputeSize for Nullable<TypeRef<'a>>
impl<'a> PrecomputeSize for Nullable<TypeRef<'a>>
sourceimpl<'a> PrecomputeSize for Nullable<VocabRef<'a>>
impl<'a> PrecomputeSize for Nullable<VocabRef<'a>>
sourceimpl PrecomputeSize for Nullable<bool>
impl PrecomputeSize for Nullable<bool>
sourceimpl Print for Nullable<Direction>
impl Print for Nullable<Direction>
fn fmt_with(
&self,
f: &mut Formatter<'_>,
_options: &Options,
_indent: usize
) -> Result<(), Error>
sourcefn pretty_print(&self) -> Printed<'_, Self>
fn pretty_print(&self) -> Printed<'_, Self>
Print the value with
Options::pretty
options.sourcefn compact_print(&self) -> Printed<'_, Self>
fn compact_print(&self) -> Printed<'_, Self>
Print the value with
Options::compact
options.sourcefn inline_print(&self) -> Printed<'_, Self>
fn inline_print(&self) -> Printed<'_, Self>
Print the value with
Options::inline
options.sourcefn print_with(&self, options: Options) -> Printed<'_, Self>
fn print_with(&self, options: Options) -> Printed<'_, Self>
Print the value with the given options.
sourceimpl<'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>
sourcefn pretty_print(&self) -> Printed<'_, Self>
fn pretty_print(&self) -> Printed<'_, Self>
Print the value with
Options::pretty
options.sourcefn compact_print(&self) -> Printed<'_, Self>
fn compact_print(&self) -> Printed<'_, Self>
Print the value with
Options::compact
options.sourcefn inline_print(&self) -> Printed<'_, Self>
fn inline_print(&self) -> Printed<'_, Self>
Print the value with
Options::inline
options.sourcefn print_with(&self, options: Options) -> Printed<'_, Self>
fn print_with(&self, options: Options) -> Printed<'_, Self>
Print the value with the given options.
sourceimpl<'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>
sourcefn pretty_print(&self) -> Printed<'_, Self>
fn pretty_print(&self) -> Printed<'_, Self>
Print the value with
Options::pretty
options.sourcefn compact_print(&self) -> Printed<'_, Self>
fn compact_print(&self) -> Printed<'_, Self>
Print the value with
Options::compact
options.sourcefn inline_print(&self) -> Printed<'_, Self>
fn inline_print(&self) -> Printed<'_, Self>
Print the value with
Options::inline
options.sourcefn print_with(&self, options: Options) -> Printed<'_, Self>
fn print_with(&self, options: Options) -> Printed<'_, Self>
Print the value with the given options.
sourceimpl<'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>
sourcefn pretty_print(&self) -> Printed<'_, Self>
fn pretty_print(&self) -> Printed<'_, Self>
Print the value with
Options::pretty
options.sourcefn compact_print(&self) -> Printed<'_, Self>
fn compact_print(&self) -> Printed<'_, Self>
Print the value with
Options::compact
options.sourcefn inline_print(&self) -> Printed<'_, Self>
fn inline_print(&self) -> Printed<'_, Self>
Print the value with
Options::inline
options.sourcefn print_with(&self, options: Options) -> Printed<'_, Self>
fn print_with(&self, options: Options) -> Printed<'_, Self>
Print the value with the given options.
sourceimpl<'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>
sourcefn pretty_print(&self) -> Printed<'_, Self>
fn pretty_print(&self) -> Printed<'_, Self>
Print the value with
Options::pretty
options.sourcefn compact_print(&self) -> Printed<'_, Self>
fn compact_print(&self) -> Printed<'_, Self>
Print the value with
Options::compact
options.sourcefn inline_print(&self) -> Printed<'_, Self>
fn inline_print(&self) -> Printed<'_, Self>
Print the value with
Options::inline
options.sourcefn print_with(&self, options: Options) -> Printed<'_, Self>
fn print_with(&self, options: Options) -> Printed<'_, Self>
Print the value with the given options.
sourceimpl<'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>
sourcefn pretty_print(&self) -> Printed<'_, Self>
fn pretty_print(&self) -> Printed<'_, Self>
Print the value with
Options::pretty
options.sourcefn compact_print(&self) -> Printed<'_, Self>
fn compact_print(&self) -> Printed<'_, Self>
Print the value with
Options::compact
options.sourcefn inline_print(&self) -> Printed<'_, Self>
fn inline_print(&self) -> Printed<'_, Self>
Print the value with
Options::inline
options.sourcefn print_with(&self, options: Options) -> Printed<'_, Self>
fn print_with(&self, options: Options) -> Printed<'_, Self>
Print the value with the given options.
sourceimpl Print for Nullable<bool>
impl Print for Nullable<bool>
fn fmt_with(
&self,
f: &mut Formatter<'_>,
options: &Options,
indent: usize
) -> Result<(), Error>
sourcefn pretty_print(&self) -> Printed<'_, Self>
fn pretty_print(&self) -> Printed<'_, Self>
Print the value with
Options::pretty
options.sourcefn compact_print(&self) -> Printed<'_, Self>
fn compact_print(&self) -> Printed<'_, Self>
Print the value with
Options::compact
options.sourcefn inline_print(&self) -> Printed<'_, Self>
fn inline_print(&self) -> Printed<'_, Self>
Print the value with
Options::inline
options.sourcefn print_with(&self, options: Options) -> Printed<'_, Self>
fn print_with(&self, options: Options) -> Printed<'_, Self>
Print the value with the given options.
sourceimpl<'a, M> PrintWithSize for Nullable<ContainerRef<'a, M>>
impl<'a, M> PrintWithSize for Nullable<ContainerRef<'a, M>>
sourceimpl<'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,
sourceimpl<T> StrippedPartialEq<Nullable<T>> for Nullable<T>where
T: StrippedPartialEq<T>,
impl<T> StrippedPartialEq<Nullable<T>> for Nullable<T>where
T: StrippedPartialEq<T>,
fn stripped_eq(&self, other: &Nullable<T>) -> bool
sourceimpl<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
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> BorrowStripped for T
impl<T> BorrowStripped for T
sourceimpl<T> BorrowUnordered for T
impl<T> BorrowUnordered for T
sourceimpl<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
sourceimpl<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,
sourcefn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key
and return true
if they are equal.