Enum json_ld::Nullable

source ·
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§

source§

impl<T> Nullable<T>

source

pub fn is_null(&self) -> bool

Checks if the value is null.

source

pub fn is_some(&self) -> bool

Checks if the value is not null.

source

pub fn unwrap(self) -> T

Unwraps a non-null value.

Panics if the value is null.

source

pub fn as_ref(&self) -> Nullable<&T>

Returns a nullabl reference to the inner value.

source

pub fn as_deref(&self) -> Nullable<&<T as Deref>::Target>
where T: Deref,

source

pub fn option(self) -> Option<T>

Transform into an Option value.

source

pub fn map<F, U>(self, f: F) -> Nullable<U>
where F: FnOnce(T) -> U,

Map the inner value using the given function.

source

pub fn cast<U>(self) -> Nullable<U>
where T: Into<U>,

source

pub fn unwrap_or(self, default: T) -> T

source

pub fn unwrap_or_default(self) -> T
where T: Default,

source§

impl<'a, T> Nullable<&'a T>
where T: Clone,

source

pub fn cloned(&self) -> Nullable<T>

Clone the referenced inner value.

Trait Implementations§

source§

impl<T> Clone for Nullable<T>
where T: Clone,

source§

fn clone(&self) -> Nullable<T>

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl<T> Debug for Nullable<T>
where T: Debug,

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
source§

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>,

Deserialize this value from the given Serde deserializer. Read more
source§

impl<T> Display for Nullable<T>
where T: Display,

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
source§

impl<T, V> DisplayWithContext<V> for Nullable<T>
where T: DisplayWithContext<V>,

source§

fn fmt_with(&self, vocabulary: &V, f: &mut Formatter<'_>) -> Result<(), Error>

source§

impl<T> From<Option<T>> for Nullable<T>

source§

fn from(value: Option<T>) -> Nullable<T>

Converts to this type from the input type.
source§

impl<T> From<T> for Nullable<T>

source§

fn from(value: T) -> Nullable<T>

Converts to this type from the input type.
source§

impl<T> Hash for Nullable<T>
where T: Hash,

source§

fn hash<__H>(&self, state: &mut __H)
where __H: Hasher,

Feeds this value into the given Hasher. Read more
1.3.0 · source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
source§

impl<T> IntoJson for Nullable<T>
where T: IntoJson,

source§

impl<T> Ord for Nullable<T>
where T: Ord,

source§

fn cmp(&self, other: &Nullable<T>) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 · source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 · source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 · source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized + PartialOrd,

Restrict a value to a certain interval. Read more
source§

impl<T> PartialEq for Nullable<T>
where T: PartialEq,

source§

fn eq(&self, other: &Nullable<T>) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl<T> PartialOrd for Nullable<T>
where T: PartialOrd,

source§

fn partial_cmp(&self, other: &Nullable<T>) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · source§

fn lt(&self, other: &Rhs) -> bool

This method tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · source§

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 more
1.0.0 · source§

fn gt(&self, other: &Rhs) -> bool

This method tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · source§

fn ge(&self, other: &Rhs) -> bool

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more
source§

impl<'a> PrecomputeSize for Nullable<&'a Container>

source§

fn pre_compute_size(&self, options: &Options, sizes: &mut Vec<Size>) -> Size

source§

impl<'a> PrecomputeSize for Nullable<&'a Id>

source§

fn pre_compute_size(&self, options: &Options, sizes: &mut Vec<Size>) -> Size

source§

impl<'a> PrecomputeSize for Nullable<&'a IriRef>

source§

fn pre_compute_size(&self, _options: &Options, _sizes: &mut Vec<Size>) -> Size

source§

impl<'a> PrecomputeSize for Nullable<&'a LenientLangTagBuf>

source§

fn pre_compute_size(&self, _options: &Options, _sizes: &mut Vec<Size>) -> Size

source§

impl<'a> PrecomputeSize for Nullable<&'a TermDefinition>

source§

fn pre_compute_size(&self, options: &Options, sizes: &mut Vec<Size>) -> Size

source§

impl<'a> PrecomputeSize for Nullable<&'a Type>

source§

fn pre_compute_size(&self, options: &Options, sizes: &mut Vec<Size>) -> Size

source§

impl<'a> PrecomputeSize for Nullable<&'a Vocab>

source§

fn pre_compute_size(&self, options: &Options, sizes: &mut Vec<Size>) -> Size

source§

impl PrecomputeSize for Nullable<Direction>

source§

fn pre_compute_size(&self, _options: &Options, _sizes: &mut Vec<Size>) -> Size

source§

impl PrecomputeSize for Nullable<IriRefBuf>

source§

fn pre_compute_size(&self, _options: &Options, _sizes: &mut Vec<Size>) -> Size

source§

impl PrecomputeSize for Nullable<bool>

source§

fn pre_compute_size(&self, options: &Options, sizes: &mut Vec<Size>) -> Size

source§

impl<'a> Print for Nullable<&'a Id>

source§

fn fmt_with( &self, f: &mut Formatter<'_>, options: &Options, indent: usize ) -> Result<(), Error>

source§

fn pretty_print(&self) -> Printed<'_, Self>

Print the value with Options::pretty options.
source§

fn compact_print(&self) -> Printed<'_, Self>

Print the value with Options::compact options.
source§

fn inline_print(&self) -> Printed<'_, Self>

Print the value with Options::inline options.
source§

fn print_with(&self, options: Options) -> Printed<'_, Self>

Print the value with the given options.
source§

impl<'a> Print for Nullable<&'a IriRef>

source§

fn fmt_with( &self, f: &mut Formatter<'_>, _options: &Options, _indent: usize ) -> Result<(), Error>

source§

fn pretty_print(&self) -> Printed<'_, Self>

Print the value with Options::pretty options.
source§

fn compact_print(&self) -> Printed<'_, Self>

Print the value with Options::compact options.
source§

fn inline_print(&self) -> Printed<'_, Self>

Print the value with Options::inline options.
source§

fn print_with(&self, options: Options) -> Printed<'_, Self>

Print the value with the given options.
source§

impl<'a> Print for Nullable<&'a LenientLangTagBuf>

source§

fn fmt_with( &self, f: &mut Formatter<'_>, _options: &Options, _indent: usize ) -> Result<(), Error>

source§

fn pretty_print(&self) -> Printed<'_, Self>

Print the value with Options::pretty options.
source§

fn compact_print(&self) -> Printed<'_, Self>

Print the value with Options::compact options.
source§

fn inline_print(&self) -> Printed<'_, Self>

Print the value with Options::inline options.
source§

fn print_with(&self, options: Options) -> Printed<'_, Self>

Print the value with the given options.
source§

impl<'a> Print for Nullable<&'a Type>

source§

fn fmt_with( &self, f: &mut Formatter<'_>, options: &Options, indent: usize ) -> Result<(), Error>

source§

fn pretty_print(&self) -> Printed<'_, Self>

Print the value with Options::pretty options.
source§

fn compact_print(&self) -> Printed<'_, Self>

Print the value with Options::compact options.
source§

fn inline_print(&self) -> Printed<'_, Self>

Print the value with Options::inline options.
source§

fn print_with(&self, options: Options) -> Printed<'_, Self>

Print the value with the given options.
source§

impl<'a> Print for Nullable<&'a Vocab>

source§

fn fmt_with( &self, f: &mut Formatter<'_>, options: &Options, indent: usize ) -> Result<(), Error>

source§

fn pretty_print(&self) -> Printed<'_, Self>

Print the value with Options::pretty options.
source§

fn compact_print(&self) -> Printed<'_, Self>

Print the value with Options::compact options.
source§

fn inline_print(&self) -> Printed<'_, Self>

Print the value with Options::inline options.
source§

fn print_with(&self, options: Options) -> Printed<'_, Self>

Print the value with the given options.
source§

impl Print for Nullable<Direction>

source§

fn fmt_with( &self, f: &mut Formatter<'_>, _options: &Options, _indent: usize ) -> Result<(), Error>

source§

fn pretty_print(&self) -> Printed<'_, Self>

Print the value with Options::pretty options.
source§

fn compact_print(&self) -> Printed<'_, Self>

Print the value with Options::compact options.
source§

fn inline_print(&self) -> Printed<'_, Self>

Print the value with Options::inline options.
source§

fn print_with(&self, options: Options) -> Printed<'_, Self>

Print the value with the given options.
source§

impl Print for Nullable<IriRefBuf>

source§

fn fmt_with( &self, f: &mut Formatter<'_>, _options: &Options, _indent: usize ) -> Result<(), Error>

source§

fn pretty_print(&self) -> Printed<'_, Self>

Print the value with Options::pretty options.
source§

fn compact_print(&self) -> Printed<'_, Self>

Print the value with Options::compact options.
source§

fn inline_print(&self) -> Printed<'_, Self>

Print the value with Options::inline options.
source§

fn print_with(&self, options: Options) -> Printed<'_, Self>

Print the value with the given options.
source§

impl Print for Nullable<bool>

source§

fn fmt_with( &self, f: &mut Formatter<'_>, options: &Options, indent: usize ) -> Result<(), Error>

source§

fn pretty_print(&self) -> Printed<'_, Self>

Print the value with Options::pretty options.
source§

fn compact_print(&self) -> Printed<'_, Self>

Print the value with Options::compact options.
source§

fn inline_print(&self) -> Printed<'_, Self>

Print the value with Options::inline options.
source§

fn print_with(&self, options: Options) -> Printed<'_, Self>

Print the value with the given options.
source§

impl<'a> PrintWithSize for Nullable<&'a Container>

source§

fn fmt_with_size( &self, f: &mut Formatter<'_>, options: &Options, indent: usize, sizes: &[Size], index: &mut usize ) -> Result<(), Error>

source§

impl<'a> PrintWithSize for Nullable<&'a TermDefinition>

source§

fn fmt_with_size( &self, f: &mut Formatter<'_>, options: &Options, indent: usize, sizes: &[Size], index: &mut usize ) -> Result<(), Error>

source§

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,

Serialize this value into the given Serde serializer. Read more
source§

impl<T> TryFromJson for Nullable<T>
where T: TryFromJson,

source§

impl<T> Copy for Nullable<T>
where T: Copy,

source§

impl<T> Eq for Nullable<T>
where T: Eq,

source§

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> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> At for T

source§

fn at<M>(self, metadata: M) -> Meta<T, M>

Wraps self inside a Meta<Self, M> using the given metadata. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> BorrowStripped for T

source§

fn stripped(&self) -> &Stripped<T>

source§

impl<T> BorrowUnordered for T

source§

impl<T> CallHasher for T
where T: Hash + ?Sized,

source§

default fn get_hash<H, B>(value: &H, build_hasher: &B) -> u64
where H: Hash + ?Sized, B: BuildHasher,

source§

impl<Q, K> Comparable<K> for Q
where Q: Ord + ?Sized, K: Borrow<Q> + ?Sized,

source§

fn compare(&self, key: &K) -> Ordering

Compare self to key and return their ordering.
source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

source§

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 Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

source§

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
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

source§

fn equivalent(&self, key: &K) -> bool

source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
source§

impl<T> From<!> for T

source§

fn from(t: !) -> T

Converts to this type from the input type.
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, C> FromWithContext<T, C> for T

source§

fn from_with(value: T, _context: &C) -> T

source§

impl<T> Instrument for T

source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U, C> IntoWithContext<U, C> for T
where U: FromWithContext<T, C>,

source§

fn into_with(self, context: &C) -> U

source§

impl<T> Same for T

§

type Output = T

Should always be Self
source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T> ToOwned for T

§

type Owned = T

source§

impl<T> ToString for T
where T: Display + ?Sized,

source§

default fn to_string(&self) -> String

Converts the given value to a String. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U, C> TryFromWithContext<U, C> for T
where U: IntoWithContext<T, C>,

§

type Error = Infallible

source§

fn try_from_with( value: U, context: &C ) -> Result<T, <T as TryFromWithContext<U, C>>::Error>

source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

impl<T, U, C> TryIntoWithContext<U, C> for T
where U: TryFromWithContext<T, C>,

§

type Error = <U as TryFromWithContext<T, C>>::Error

source§

fn try_into_with( self, context: &C ) -> Result<U, <T as TryIntoWithContext<U, C>>::Error>

source§

impl<T> WithContext for T
where T: ?Sized,

source§

fn with<C>(&self, context: C) -> Contextual<&T, C>

source§

fn into_with<C>(self, context: C) -> Contextual<T, C>

source§

impl<T> WithSubscriber for T

source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

source§

impl<V, T> RdfLiteralType<V> for T

source§

impl<T> RdfLiteralValue for T
where T: From<String> + From<Value> + From<Value>,