Subclass

Trait Subclass 

Source
pub unsafe trait Subclass<T: Superclass> {
    // Required method
    fn vmt_rva() -> Rva;

    // Provided methods
    fn vmt_va() -> Va { ... }
    fn superclass(&self) -> &T { ... }
    fn superclass_mut(&mut self) -> &mut T { ... }
}
Expand description

A trait for C++ subclasses of the superclass T. Implementing this trait makes it possible for Rust code to be generic over all subclasses of a given C++ supertype.

§Safety

In order to implement this for a struct, you must guarantee:

  • The struct uses C-style layout.
  • An initial subsequence of the struct is a valid isntance of T.

Required Methods§

Source

fn vmt_rva() -> Rva

The RVA of this class’s virtual method table.

Provided Methods§

Source

fn vmt_va() -> Va

The VA of this class’s virtual method table.

Source

fn superclass(&self) -> &T

Returns this as a T.

Source

fn superclass_mut(&mut self) -> &mut T

Returns this as a mutable T.

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§

Source§

impl<T> Subclass<T> for T
where T: Superclass,