pub struct ArchivedOptionBox<T: ArchivePointee + ?Sized> { /* private fields */ }
Expand description

A niched archived Option<Box<T>>.

It uses less space by storing the None variant as a null pointer.

Implementations§

source§

impl<T: ArchivePointee + ?Sized> ArchivedOptionBox<T>

source

pub fn is_none(&self) -> bool

Returns true if the option box is a None value.

source

pub fn is_some(&self) -> bool

Returns true if the option box is a Some value.

source

pub fn as_ref(&self) -> Option<&ArchivedBox<T>>

Converts to an Option<&ArchivedBox<T>>.

source

pub fn as_mut(&mut self) -> Option<&mut ArchivedBox<T>>

Converts to an Option<&mut ArchivedBox<T>>.

source

pub fn as_pin_ref(self: Pin<&Self>) -> Option<Pin<&ArchivedBox<T>>>

Converts from Pin<&ArchivedOptionBox<T>> to Option<Pin<&ArchivedBox<T>>>.

source

pub fn as_pin_mut(self: Pin<&mut Self>) -> Option<Pin<&mut ArchivedBox<T>>>

Converts from Pin<&mut ArchivedOption<T>> to Option<Pin<&mut ArchivedBox<T>>>.

source

pub fn iter(&self) -> Iter<'_, ArchivedBox<T>>

Returns an iterator over the possibly contained value.

source

pub fn iter_mut(&mut self) -> IterMut<'_, ArchivedBox<T>>

Returns a mutable iterator over the possibly contained value.

source

pub fn as_deref(&self) -> Option<&T>

Converts from &ArchivedOptionBox<T> to Option<&T>.

Leaves the original ArchivedOptionBox in-place, creating a new one with a reference to the original one.

source§

impl<T: ArchivePointee + ?Sized> ArchivedOptionBox<T>

source

pub unsafe fn resolve_from_option<U: ArchiveUnsized<Archived = T> + ?Sized>( field: Option<&U>, pos: usize, resolver: OptionBoxResolver<U::MetadataResolver>, out: *mut Self )

Resolves an ArchivedOptionBox<T::Archived> from an Option<&T>.

Safety
  • pos must be the position of out within the archive
  • resolver must be the result of serializing field
source

pub fn serialize_from_option<U, S>( field: Option<&U>, serializer: &mut S ) -> Result<OptionBoxResolver<U::MetadataResolver>, S::Error>
where U: SerializeUnsized<S, Archived = T> + ?Sized, S: Serializer + ?Sized,

Serializes an ArchivedOptionBox<T::Archived> from an Option<&T>.

Trait Implementations§

source§

impl<T: ArchivePointee + ?Sized> Debug for ArchivedOptionBox<T>

source§

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

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

impl<T, D> DeserializeWith<ArchivedOptionBox<<T as ArchiveUnsized>::Archived>, Option<Box<T>>, D> for Niche

source§

fn deserialize_with( field: &ArchivedOptionBox<T::Archived>, deserializer: &mut D ) -> Result<Option<Box<T>>, D::Error>

Deserializes the field type F using the given deserializer.
source§

impl<T: ArchivePointee + Hash + ?Sized> Hash for ArchivedOptionBox<T>

source§

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

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: ArchivePointee + Ord + ?Sized> Ord for ArchivedOptionBox<T>

source§

fn cmp(&self, other: &Self) -> 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, U> PartialEq<ArchivedOptionBox<T>> for Option<Box<U>>
where T: ArchivePointee + PartialEq<U> + ?Sized, U: ?Sized,

source§

fn eq(&self, other: &ArchivedOptionBox<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, U> PartialEq<Option<Box<T>>> for ArchivedOptionBox<U>
where T: ?Sized, U: ArchivePointee + PartialEq<T> + ?Sized,

source§

fn eq(&self, other: &Option<Box<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: ArchivePointee + PartialEq + ?Sized> PartialEq for ArchivedOptionBox<T>

source§

fn eq(&self, other: &Self) -> 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: ArchivePointee + PartialOrd + ?Sized> PartialOrd for ArchivedOptionBox<T>

source§

fn partial_cmp(&self, other: &Self) -> 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<T: ArchivePointee + Eq + ?Sized> Eq for ArchivedOptionBox<T>

Auto Trait Implementations§

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> ArchivePointee for T

§

type ArchivedMetadata = ()

The archived version of the pointer metadata for this type.
source§

fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata ) -> <T as Pointee>::Metadata

Converts some archived metadata to the pointer metadata for itself.
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> CallHasher for T
where T: Hash + ?Sized,

source§

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

source§

impl<F, W, T, D> Deserialize<With<T, W>, D> for F
where W: DeserializeWith<F, T, D>, D: Fallible + ?Sized, F: ?Sized,

source§

fn deserialize( &self, deserializer: &mut D ) -> Result<With<T, W>, <D as Fallible>::Error>

Deserializes using the given deserializer
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

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> Pointee for T

§

type Metadata = ()

The type for metadata in pointers and references to Self.
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> 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.