Enum rkyv::option::ArchivedOption

source ·
#[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_seal(this: Seal<'_, Self>) -> Option<Seal<'_, T>>

Converts from Seal<'_, ArchivedOption<T>> to Option<Seal<'_, T>>.

source

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

Returns an iterator over the possibly-contained value.

source

pub fn iter_mut(&mut self) -> Iter<&mut T>

Returns an iterator over the mutable possibly-contained value.

source

pub fn iter_seal(this: Seal<'_, Self>) -> Iter<Seal<'_, T>>

Returns an iterator over the sealed 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<T, __C: Fallible + ?Sized> CheckBytes<__C> for ArchivedOption<T>
where <__C as Fallible>::Error: Source, T: CheckBytes<__C>,

source§

unsafe fn check_bytes( value: *const Self, context: &mut __C, ) -> Result<(), <__C as Fallible>::Error>

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, D> Deserialize<Option<T>, D> for ArchivedOption<T::Archived>
where T: Archive, T::Archived: Deserialize<T, D>, D: Fallible + ?Sized,

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!(matches!(o, ArchivedOption::Some(67)));
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<'a, T> IntoIterator for &'a ArchivedOption<T>

source§

type Item = &'a T

The type of the elements being iterated over.
source§

type IntoIter = Iter<&'a T>

Which kind of iterator are we turning this into?
source§

fn into_iter(self) -> Self::IntoIter

Creates an iterator from a value. Read more
source§

impl<'a, T> IntoIterator for &'a mut ArchivedOption<T>

source§

type Item = &'a mut T

The type of the elements being iterated over.
source§

type IntoIter = Iter<&'a mut T>

Which kind of iterator are we turning this into?
source§

fn into_iter(self) -> Self::IntoIter

Creates an iterator from a value. 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, U: PartialEq<T>> PartialEq<Option<T>> for ArchivedOption<U>

source§

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

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

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

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

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

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

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

impl<T, U: PartialOrd<T>> PartialOrd<Option<T>> for ArchivedOption<U>

source§

fn partial_cmp(&self, other: &Option<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

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

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

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

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
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

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

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

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

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>

source§

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

Auto Trait Implementations§

§

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

§

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

source§

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> CloneToUninit for T
where T: Clone,

source§

unsafe fn clone_to_uninit(&self, dst: *mut T)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. 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

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

Returns the layout of the type.
source§

impl<T> Pointee for T

source§

type Metadata = ()

The metadata type for pointers and references to this type.
source§

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

source§

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

source§

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

source§

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.