Inherit

Trait Inherit 

Source
pub trait Inherit {
    type Parent;

    // Required methods
    fn parent<'a>(&'a self) -> &'a Self::Parent;
    fn parent_mut<'a>(&'a mut self) -> &'a mut Self::Parent;
}
Expand description

Trait useful for Java-style inheritance. It allows T to implement all of parent’s methods if the parent’s methods live in a trait with a default implementation for T : Inherit. Note this trait only allows for single-parent relationships (tree-like inheritance diagram). For multiple inheritance (DAG-like inheritance diagram) Parent should be a trait type argument. A way to simulate multiple inheritance is to use Type Parent = (A, B), then to use the fields/methods of A use parent().0 and to use the fields/methods of B use parent().1 *

Required Associated Types§

Required Methods§

Source

fn parent<'a>(&'a self) -> &'a Self::Parent

Source

fn parent_mut<'a>(&'a mut self) -> &'a mut Self::Parent

Implementors§