pub unsafe trait Inherits<I: Interface>: Interface { }
Expand description

Represents the “is-a” relationship for interfaces.

If interface I implements Inherits<J>, it is valid to cast a pointer of type *mut I to a pointer of type *mut J and to call any of J’s methods via that pointer.

The Inherits relation should be reflexive and transitive, i.e. I: Inherits<I> should be true for any type I, and if I: Inherits<J> and J: Inherits<K> are true, then I: Inherits<K> should also be true. However, this is not a safety requirement.

§Safety

Interface is a supertrait of Inherits, so all of Interface’s safety requirements also apply to Inherits. In particular, if I implements Inherits, it must have the same layout as the pointer type *const I::Vtbl.

If I implements Inherits<J>, then the layout of J::Vtbl must be a prefix of the layout of I::Vtbl, i.e. a valid pointer to an instance of I::Vtbl must also be a valid pointer to an instance of J::Vtbl.

Object Safety§

This trait is not object safe.

Implementors§

source§

impl<I: Interface> Inherits<I> for I