rune::core::gc::root

Trait RootedDeref

Source
pub trait RootedDeref {
    type Target;

    // Required methods
    fn rooted_deref(rooted: &Rt<Self>) -> &Self::Target;
    fn rooted_derefmut(rooted: &mut Rt<Self>) -> &mut Self::Target;
}
Expand description

Trait created to overpass the orphan rule when deriving the Trace derive macro. The derive macro contains a blanket Deref (and DerefMut) like this:

unsafe { &*(rt as *const Rt<Self>).cast::<Self::Target>() }

By creating a trait that the functions defined in the main crate can define, we avoid the orphan rule by implementing Deref on the rooted version of the types: Rt<T>.

Required Associated Types§

Required Methods§

Source

fn rooted_deref(rooted: &Rt<Self>) -> &Self::Target

Source

fn rooted_derefmut(rooted: &mut Rt<Self>) -> &mut Self::Target

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§