pub enum Nullable<T> {
    ImplicitNull,
    ExplicitNull,
    Some(T),
}
Expand description

Nullable can be used in situations where you need to distinguish between an implicitly and explicitly null input value.

The GraphQL spec states that these two field calls are similar, but are not identical:

{
  field(arg: null)
  field
}

The first has explicitly provided null to the argument “arg”, while the second has implicitly not provided a value to the argument “arg”. These two forms may be interpreted differently. For example, a mutation representing deleting a field vs not altering a field, respectively.

In cases where you do not need to be able to distinguish between the two types of null, you should simply use Option<T>.

Variants

ImplicitNull

No value

ExplicitNull

No value, explicitly specified to be null

Some(T)

Some value T

Implementations

Returns true if the nullable is a ExplicitNull value.

Returns true if the nullable is a ImplicitNull value.

Returns true if the nullable is a Some value.

Returns true if the nullable is not a Some value.

Converts from &mut Nullable<T> to Nullable<&mut T>.

Returns the contained Some value, consuming the self value.

Panics

Panics if the value is not a Some with a custom panic message provided by msg.

Returns the contained Some value or a provided default.

Returns the contained Some value or computes it from a closure.

Maps a Nullable<T> to Nullable<U> by applying a function to a contained value.

Applies a function to the contained value (if any), or returns the provided default (if not).

Applies a function to the contained value (if any), or computes a default (if not).

Transforms the Nullable<T> into a Result<T, E>, mapping Some(v) to Ok(v) and ImplicitNull or ExplicitNull to Err(err).

Transforms the Nullable<T> into a Result<T, E>, mapping Some(v) to Ok(v) and ImplicitNull or ExplicitNull to Err(err()).

Returns the nullable if it contains a value, otherwise returns b.

Returns the nullable if it contains a value, otherwise calls f and returns the result.

Replaces the actual value in the nullable by the value given in parameter, returning the old value if present, leaving a Some in its place without deinitializing either one.

Converts from Nullable<T> to Option<T>.

Converts from Nullable<T> to Option<Option<T>>, mapping Some(v) to Some(Some(v)), ExplicitNull to Some(None), and ImplicitNull to None.

Maps a Nullable<&T> to a Nullable<T> by copying the contents of the nullable.

Maps a Nullable<&mut T> to a Nullable<T> by copying the contents of the nullable.

Maps a Nullable<&T> to a Nullable<T> by cloning the contents of the nullable.

Maps a Nullable<&mut T> to a Nullable<T> by cloning the contents of the nullable.

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Returns the “default value” for a type. Read more

Performs the conversion.

Performs the conversion from an absent value (e.g. to distinguish between implicit and explicit null). The default implementation just uses from_input_value as if an explicit null were provided. This conversion must not fail. Read more

Returns name of this GraphQLType to expose. Read more

Returns MetaType representing this GraphQLType.

Context type for this GraphQLValue. Read more

Type that may carry additional schema information for this GraphQLValue. Read more

Returns name of the GraphQLType exposed by this GraphQLValue. Read more

Resolves the provided selection_set against this GraphQLValue. Read more

Resolves the value of a single field on this GraphQLValue. Read more

Resolves this GraphQLValue (being an interface or an union) into a concrete downstream object type. Read more

Returns the concrete GraphQLType name for this GraphQLValue being an interface, an union or an object. Read more

Resolves the provided selection_set against this GraphQLValueAsync. Read more

Resolves the value of a single field on this GraphQLValueAsync. Read more

Resolves this GraphQLValueAsync (being an interface or an union) into a concrete downstream object type. Read more

Feeds this value into the given Hasher. Read more

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

An arbitrary function without meaning. Read more

This method returns an Ordering between self and other. Read more

Compares and returns the maximum of two values. Read more

Compares and returns the minimum of two values. Read more

Restrict a value to a certain interval. Read more

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

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

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

This method tests less than or equal to (for self and other) and is used by the <= operator. Read more

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

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

Performs the conversion.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Compare self to key and return true if they are equal.

Returns the argument unchanged.

Calls U::from(self).

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

The resulting type after obtaining ownership.

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

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

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.