[][src]Trait downcast_trait::DowncastTrait

pub trait DowncastTrait {
    unsafe fn convert_to_trait(&self, trait_id: TypeId) -> Option<&dyn Any>;
unsafe fn convert_to_trait_mut(
        &mut self,
        trait_id: TypeId
    ) -> Option<&mut dyn Any>;
fn to_downcast_trait(&self) -> &dyn DowncastTrait;
fn to_downcast_trait_mut(&mut self) -> &mut dyn DowncastTrait; }

This trait should be implemented by any structs that or traits that should be downcastable to dowcast to one or more traits. The functions required by this trait should be implemented using the downcast_trait_impl_convert_to macro.

This example is not tested
trait Widget: DowncastTrait {}

Required methods

unsafe fn convert_to_trait(&self, trait_id: TypeId) -> Option<&dyn Any>

Safety

This function is called by the downcast_trait macro and should not be accessed directly.

unsafe fn convert_to_trait_mut(
    &mut self,
    trait_id: TypeId
) -> Option<&mut dyn Any>

Safety

This function is called by the downcast_trait_mut macro and should not be accessed directly.

fn to_downcast_trait(&self) -> &dyn DowncastTrait

This macro is used to cast any implementer of this trait to a DowncastTrait

fn to_downcast_trait_mut(&mut self) -> &mut dyn DowncastTrait

This macro is used to cast any implementer of this trait to a mut DowncastTrait

Loading content...

Implementors

Loading content...