#[repr(u8)]
pub enum ArchivedOption<T> { None, Some(T), }
Expand description

An archived Option.

It functions identically to Option but has a different internal representation to allow for archiving.

Variants§

§

None

No value

§

Some(T)

Some value T

Implementations§

source§

impl<T> ArchivedOption<T>

source

pub fn ok_or<E>(self, err: E) -> Result<T, E>

Transforms the ArchivedOption<T> into a Result<T, E>, mapping Some(v) to Ok(v) and None to Err(err).

source

pub fn unwrap(self) -> T

Returns the contained Some value, consuming the self value.

source

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

Returns the contained Some value or a provided default.

source

pub fn unwrap_or_else<F: FnOnce() -> T>(self, f: F) -> T

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

source

pub fn is_none(&self) -> bool

Returns true if the option is a None value.

source

pub fn is_some(&self) -> bool

Returns true if the option is a Some value.

source

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

Converts to an Option<&T>.

source

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

Converts to an Option<&mut T>.

source

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

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

source

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

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

source

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

Returns an iterator over the possibly contained value.

source

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

Returns a mutable iterator over the possibly contained value.

source

pub fn get_or_insert(&mut self, v: T) -> &mut T

Inserts v into the option if it is None, then returns a mutable reference to the contained value.

source

pub fn get_or_insert_with<F: FnOnce() -> T>(&mut self, f: F) -> &mut T

Inserts a value computed from f into the option if it is None, then returns a mutable reference to the contained value.

source§

impl<T: Deref> ArchivedOption<T>

source

pub fn as_deref(&self) -> Option<&<T as Deref>::Target>

Converts from &ArchivedOption<T> to Option<&T::Target>.

Leaves the original ArchivedOption in-place, creating a new one with a reference to the original one, additionally coercing the contents via Deref.

source§

impl<T: DerefMut> ArchivedOption<T>

source

pub fn as_deref_mut(&mut self) -> Option<&mut <T as Deref>::Target>

Converts from &mut ArchivedOption<T> to Option<&mut T::Target>.

Leaves the original ArchivedOption in-place, creating a new Option with a mutable reference to the inner type’s Deref::Target type.

Trait Implementations§

source§

impl<__C: ?Sized, T> CheckBytes<__C> for ArchivedOption<T>
where T: CheckBytes<__C>,

§

type Error = EnumCheckError<u8>

The error that may result from checking the type.
source§

unsafe fn check_bytes<'__bytecheck>( value: *const Self, context: &mut __C ) -> Result<&'__bytecheck Self, EnumCheckError<u8>>

Checks whether the given pointer points to a valid value within the given context. Read more
source§

impl<T: Clone> Clone for ArchivedOption<T>

source§

fn clone(&self) -> ArchivedOption<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> Debug for ArchivedOption<T>

source§

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

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

impl<T: Archive, D: Fallible + ?Sized> Deserialize<Option<T>, D> for ArchivedOption<T::Archived>
where T::Archived: Deserialize<T, D>,

source§

fn deserialize(&self, deserializer: &mut D) -> Result<Option<T>, D::Error>

Deserializes using the given deserializer
source§

impl<A, O, D> DeserializeWith<ArchivedOption<<A as ArchiveWith<O>>::Archived>, Option<O>, D> for Map<A>
where D: Fallible + ?Sized, A: ArchiveWith<O> + DeserializeWith<<A as ArchiveWith<O>>::Archived, O, D>,

source§

fn deserialize_with( field: &ArchivedOption<<A as ArchiveWith<O>>::Archived>, d: &mut D ) -> Result<Option<O>, D::Error>

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

impl<T> From<T> for ArchivedOption<T>

source§

fn from(val: T) -> ArchivedOption<T>

Moves val into a new Some.

§Examples
let o: ArchivedOption<u8> = ArchivedOption::from(67);

assert_eq!(Some(67), o);
source§

impl<T: Hash> Hash for ArchivedOption<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: Ord> Ord for ArchivedOption<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: PartialEq<U>, U> PartialEq<ArchivedOption<T>> for Option<U>

source§

fn eq(&self, other: &ArchivedOption<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<T>> PartialEq<Option<T>> for ArchivedOption<U>

source§

fn eq(&self, other: &Option<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: PartialEq> PartialEq for ArchivedOption<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: PartialOrd> PartialOrd for ArchivedOption<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: Copy> Copy for ArchivedOption<T>

source§

impl<T: Eq> Eq for ArchivedOption<T>

Auto Trait Implementations§

§

impl<T> RefUnwindSafe for ArchivedOption<T>
where T: RefUnwindSafe,

§

impl<T> Send for ArchivedOption<T>
where T: Send,

§

impl<T> Sync for ArchivedOption<T>
where T: Sync,

§

impl<T> Unpin for ArchivedOption<T>
where T: Unpin,

§

impl<T> UnwindSafe for ArchivedOption<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> 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
§

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

§

default 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<!> 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, 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> LayoutRaw for T

source§

fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>

Gets the layout of the type.
source§

impl<T> Pointee for T

§

type Metadata = ()

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