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§
Provided Methods§
Sourcefn superclass(&self) -> &T
fn superclass(&self) -> &T
Returns this as a T.
Sourcefn superclass_mut(&mut self) -> &mut T
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.