[−][src]Trait better_any::TidExt
Extension trait that contains actual downcasting methods.
Use methods from this trait only if dyn Tid
was created directly from T
for this particular T
Required methods
fn is<T: Tid<'a>>(&self) -> bool
Returns true if type behind self is equal to the type of T.
fn downcast_ref<'b, T: Tid<'a>>(&'b self) -> Option<&'b T>
Attempts to downcast self to T
behind reference
fn downcast_mut<'b, T: Tid<'a>>(&'b mut self) -> Option<&'b mut T>
Attempts to downcast self to T
behind mutable reference
fn downcast_rc<T: Tid<'a>>(self: Rc<Self>) -> Result<Rc<T>, Rc<Self>>
Attempts to downcast self to T
behind Rc
pointer
fn downcast_arc<T: Tid<'a>>(self: Arc<Self>) -> Result<Arc<T>, Arc<Self>>
Attempts to downcast self to T
behind Arc
pointer
fn downcast_box<T: Tid<'a>>(self: Box<Self>) -> Result<Box<T>, Box<Self>>
Attempts to downcast self to T
behind Box
pointer
Implementors
impl<'a, X: ?Sized + Tid<'a>> TidExt<'a> for X
[src]
If X is Sized then any of those calls is optimized to no-op because both T and Self are known statically. Useful if you have generic code that you want to behave differently depending on which concrete type replaces type parameter. Usually there are better ways to do this like specialization, but sometimes it can be the only way.