[−][src]Struct traitcast_core::Registry
A registry defining how to cast into some set of traits.
Fields
tables: Map<dyn Any + Sync>
Methods
impl Registry
[src]
pub fn new() -> Registry
[src]
Makes a new, empty trait registry.
pub fn insert<DynTrait: ?Sized + 'static>(
&mut self,
table: CastIntoTrait<DynTrait>
)
[src]
&mut self,
table: CastIntoTrait<DynTrait>
)
Updates the table defining how to cast into the given trait.
pub fn cast_into<To: ?Sized>(&self) -> Option<&CastIntoTrait<To>> where
To: 'static,
[src]
To: 'static,
Gets the table defining how to cast into the given trait.
This method is designed to be chained with from_mut, from_ref or from_box.
Examples
let x: &dyn Bar = ...;
registry.cast_into::<Foo>()?.from_ref(x)
let x: &mut dyn Bar = ...;
registry.cast_into::<Foo>()?.from_mut(x)
let x: Box<dyn Bar> = ...;
registry.cast_into::<Foo>()?.from_box(x)
Auto Trait Implementations
Blanket Implementations
impl<T> TraitcastFrom for T where
T: 'static,
[src]
T: 'static,
fn as_any_ref(&Self) -> &(dyn Any + 'static)
[src]
fn as_any_mut(&mut Self) -> &mut (dyn Any + 'static)
[src]
fn as_any_box(Box<T>) -> Box<dyn Any + 'static>
[src]
fn type_id(&self) -> TypeId
[src]
Get the trait object's dynamic type id.
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> From<T> for T
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Any for T where
T: Any,
[src]
T: Any,