unsafe_any

Trait UnsafeAnyExt

Source
pub unsafe trait UnsafeAnyExt {
    // Provided methods
    unsafe fn downcast_ref_unchecked<T: Any>(&self) -> &T { ... }
    unsafe fn downcast_mut_unchecked<T: Any>(&mut self) -> &mut T { ... }
    unsafe fn downcast_unchecked<T: Any>(self: Box<Self>) -> Box<T> { ... }
}
Expand description

An extension trait for unchecked downcasting of trait objects.

Provided Methods§

Source

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

Returns a reference to the contained value, assuming that it is of type T.

§Warning

If you are not absolutely certain of T you should not call this!

Source

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

Returns a mutable reference to the contained value, assuming that it is of type T.

§Warning

If you are not absolutely certain of T you should not call this!

Source

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

Returns a the contained value, assuming that it is of type T.

§Warning

If you are not absolutely certain of T you should not call this!

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementations on Foreign Types§

Source§

impl UnsafeAnyExt for dyn Any

Source§

impl UnsafeAnyExt for dyn Any + Send

Source§

impl UnsafeAnyExt for dyn Any + Send + Sync

Source§

impl UnsafeAnyExt for dyn Any + Sync

Implementors§