January 2019
Beginner to intermediate
554 pages
13h 31m
English
We already saw these traits in our trait_inheritance.rs code example. Unlike types in Rust, traits can have an inheritance relationship, for instance:
trait Bar { fn bar();}trait Foo: Bar { fn foo();}
In the preceding snippet , we declared a trait, Foo, that depends on a super trait, Bar. The definition of Foo mandates implementing Bar whenever you are implementing Foo for your type. One such example from the standard library is the Copy trait, which requires the type to also implement the Clone trait.
Read now
Unlock full access