Skip to main content

Cast

Trait Cast 

pub trait Cast: SystemObject {
    // Provided methods
    fn get_class(self) -> Class { ... }
    fn is_null(self) -> bool { ... }
    fn rebind_class(self, new_class: Class) { ... }
    fn override_class(self) -> Class { ... }
    fn is_instance_of<T>(self) -> bool
       where T: ClassIdentity { ... }
    fn is_direct_subclass_of<T>(self) -> bool
       where T: ClassIdentity { ... }
    fn try_cast<T>(self) -> Option<T>
       where T: ClassIdentity + FromIlInstance { ... }
    unsafe fn cast<T>(self) -> T
       where T: ClassIdentity + FromIlInstance { ... }
}

Provided Methods§

fn get_class(self) -> Class

fn is_null(self) -> bool

fn rebind_class(self, new_class: Class)

fn override_class(self) -> Class

fn is_instance_of<T>(self) -> bool
where T: ClassIdentity,

fn is_direct_subclass_of<T>(self) -> bool
where T: ClassIdentity,

fn try_cast<T>(self) -> Option<T>

unsafe fn cast<T>(self) -> T

§Safety

Caller must guarantee that self is actually an instance of T (or a subtype). Skips the runtime class check that try_cast performs.

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.

Implementors§

§

impl<T> Cast for T
where T: SystemObject,