Trait ezty::AnyDebug

source ·
pub trait AnyDebug: Any + Debug + Send + Sync {
    // Required method
    fn get_ty(&self) -> Ty;

    // Provided method
    fn type_name(&self) -> &'static str { ... }
}
Expand description

Like Any, but with Debug, Send, & Sync.

Required Methods§

source

fn get_ty(&self) -> Ty

You’re inevitably wanting to call this with something like Box<dyn AnyDebug>, but instead of returning the ty of the contents, it uselessly returns Ty::of::<Box<dyn AnyDebug>>(). How do you deal with this? Instead of this.get_ty(), call (*this).get_ty().

Provided Methods§

source

fn type_name(&self) -> &'static str

Implementations§

source§

impl dyn AnyDebug

source

pub fn is<T: AnyDebug>(&self) -> bool

Returns true if the boxed type is the same as T

source

pub fn downcast_ref<T: AnyDebug>(&self) -> Option<&T>

Returns some reference to the boxed value if it is of type T, or None if it isn’t.

source

pub unsafe fn downcast_ref_unchecked<T: AnyDebug>(&self) -> &T

Returns a reference to the boxed value, blindly assuming it to be of type T. If you are not absolutely certain of T, you must not call this.

source

pub fn downcast_mut<T: AnyDebug>(&mut self) -> Option<&mut T>

Returns some mutable reference to the boxed value if it is of type T, or None if it isn’t.

source

pub unsafe fn downcast_mut_unchecked<T: AnyDebug>(&mut self) -> &mut T

Returns a mutable reference to the boxed value, blindly assuming it to be of type T. If you are not absolutely certain of T, you must not call this.

source§

impl dyn AnyDebug

source

pub fn downcast<T: AnyDebug>(self: Box<Self>) -> Result<Box<T>, Box<Self>>

Returns the boxed value if it is of type T, or Err(Self) if it isn’t.

source

pub unsafe fn downcast_unchecked<T: AnyDebug>(self: Box<Self>) -> Box<T>

Returns the boxed value, blindly assuming it to be of type T. If you are not absolutely certain of T, you must not call this.

Implementors§

source§

impl<X: Any + Debug + Send + Sync> AnyDebug for X