Tagged

Trait Tagged 

Source
pub unsafe trait Tagged<'a>: Sealed + 'a {
    // Required method
    fn tag_id(&self) -> TypeId;
}
Expand description

Sealed trait representing a type-erased tagged object.

Required Methods§

Source

fn tag_id(&self) -> TypeId

The TypeId of the Tag this value was tagged with.

Implementations§

Source§

impl<'a> dyn Tagged<'a>

Source

pub fn tag_ref<I>(value: &I::Type) -> &dyn Tagged<'a>
where I: Tag<'a>,

Tag a reference to a concrete type with a given Tag.

This is like an unsizing coercion, but must be performed explicitly to specify the specific tag.

Source

pub fn tag_mut<I>(value: &mut I::Type) -> &mut dyn Tagged<'a>
where I: Tag<'a>,

Tag a reference to a concrete type with a given Tag.

This is like an unsizing coercion, but must be performed explicitly to specify the specific tag.

Source

pub fn tag_box<I>(value: Box<I::Type>) -> Box<dyn Tagged<'a>>
where I: Tag<'a>,

Tag a Box of a concrete type with a given Tag.

This is like an unsizing coercion, but must be performed explicitly to specify the specific tag.

Source

pub fn is<I>(&self) -> bool
where I: Tag<'a>,

Returns true if the dynamic type is tagged with I.

Source

pub fn downcast_ref<I>(&self) -> Option<&I::Type>
where I: Tag<'a>,

Returns some reference to the dynamic value if it is tagged with I, or None if it isn’t.

Source

pub fn downcast_mut<I>(&mut self) -> Option<&mut I::Type>
where I: Tag<'a>,

Returns some reference to the dynamic value if it is tagged with I, or None if it isn’t.

Source

pub fn downcast_box<I>(self: Box<Self>) -> Result<Box<I::Type>, Box<Self>>
where I: Tag<'a>,

Implementors§