Struct TaggedOption

#[repr(transparent)]
pub(crate) struct TaggedOption<'a, I: Type<'a>>(pub Option<I::Reified>);

An Option with a type tag I.

Since this struct implements Erased, the type can be erased to make a dynamically typed option. The type can be checked dynamically using Tagged::tag_id and since this is statically checked for the concrete type, there is some degree of type safety.

Fields

0: Option<I::Reified>

Trait Implementations

impl<'a, I: Type<'a>> Erased<'a> for TaggedOption<'a, I>

Auto Trait Implementations

impl<'a, I> Freeze for TaggedOption<'a, I> where Option<<I as Type<'a>>::Reified>: Freeze,

impl<'a, I> RefUnwindSafe for TaggedOption<'a, I> where Option<<I as Type<'a>>::Reified>: RefUnwindSafe,

impl<'a, I> Send for TaggedOption<'a, I> where Option<<I as Type<'a>>::Reified>: Send,

impl<'a, I> Sync for TaggedOption<'a, I> where Option<<I as Type<'a>>::Reified>: Sync,

impl<'a, I> Unpin for TaggedOption<'a, I> where Option<<I as Type<'a>>::Reified>: Unpin,

impl<'a, I> UnsafeUnpin for TaggedOption<'a, I> where Option<<I as Type<'a>>::Reified>: UnsafeUnpin,

impl<'a, I> UnwindSafe for TaggedOption<'a, I> where Option<<I as Type<'a>>::Reified>: UnwindSafe,

Blanket Implementations

impl<T> Any for TaggedOption<'a, I> where T: 'static + ?Sized,

fn type_id(&self) -> TypeId

impl<T> Borrow<T> for TaggedOption<'a, I> where T: ?Sized,

fn borrow(&self) -> &T

impl<T> BorrowMut<T> for TaggedOption<'a, I> where T: ?Sized,

fn borrow_mut(&mut self) -> &mut T

impl<T> From<T> for TaggedOption<'a, I>

fn from(t: T) -> T

Returns the argument unchanged.

impl<T> SizeHint for TaggedOption<'a, I> where T: ?Sized,

fn lower_bound(&self) -> usize
fn upper_bound(&self) -> Option<usize>

impl<T> SizedTypeProperties for TaggedOption<'a, I>

impl<T, U> Into<U> for TaggedOption<'a, I> where U: From<T>,

fn into(self) -> U

Calls U::from(self).

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

impl<T, U> TryFrom<U> for TaggedOption<'a, I> where U: Into<T>,

type Error = Infallible;
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

impl<T, U> TryInto<U> for TaggedOption<'a, I> where U: TryFrom<T>,

type Error = <U as TryFrom<T>>::Error;
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>