pub enum Nullable<T> {
Absent,
Null,
Value(T),
}Expand description
An optional, nullable member: absent, an explicit null, or a value.
Default is Absent, so a member nobody sets is left off the wire. From<T> gives Value,
so a generated with_<field> setter taking impl Into<Nullable<T>> accepts a value or
Nullable::Null, and its with_<field>_null() sibling stores that Null. An Option<T>
converts to neither: whether its None means “leave the member alone” (Absent) or “clear
it” (Null) is the caller’s to spell out.
Variants§
Absent
The member is left off the wire, or was missing from what was decoded.
Null
The member is an explicit null.
Value(T)
The member holds a value.
Implementations§
Source§impl<T> Nullable<T>
impl<T> Nullable<T>
Sourcepub fn is_absent(&self) -> bool
pub fn is_absent(&self) -> bool
Whether the member is absent: the predicate a generated field’s skip_serializing_if
names.
Sourcepub fn as_option(&self) -> Option<&T>
pub fn as_option(&self) -> Option<&T>
The value, borrowed: Some for Value, and None for both Null and Absent.
Sourcepub fn into_option(self) -> Option<T>
pub fn into_option(self) -> Option<T>
The value: Some for Value, and None for both Null and Absent.
Trait Implementations§
impl<T: Copy> Copy for Nullable<T>
Source§impl<'de, T: Deserialize<'de>> Deserialize<'de> for Nullable<T>
impl<'de, T: Deserialize<'de>> Deserialize<'de> for Nullable<T>
Source§fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
impl<T: Eq> Eq for Nullable<T>
Source§impl<T: Ord> Ord for Nullable<T>
impl<T: Ord> Ord for Nullable<T>
1.21.0 (const: unstable) · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Source§impl<T: PartialEq> PartialEq for Nullable<T>
impl<T: PartialEq> PartialEq for Nullable<T>
Source§impl<T: PartialOrd> PartialOrd for Nullable<T>
impl<T: PartialOrd> PartialOrd for Nullable<T>
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> 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
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,
§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
§impl<T> CompatExt for T
impl<T> CompatExt for T
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.§impl<T, UT> HandleAlloc<UT> for T
impl<T, UT> HandleAlloc<UT> for T
§fn new_handle(value: Arc<T>) -> Handle
fn new_handle(value: Arc<T>) -> Handle
§unsafe fn clone_handle(handle: Handle) -> Handle
unsafe fn clone_handle(handle: Handle) -> Handle
§unsafe fn consume_handle(handle: Handle) -> Arc<T> ⓘ
unsafe fn consume_handle(handle: Handle) -> Arc<T> ⓘ
Arc<> Read more§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more