本页尚未翻译,以下为英文原文。
#E0077: supertrait not implemented
A trait requires another trait (its supertrait), and the type does not implement it. Implement the supertrait for the type too.
nabi
trait Base { fn id(self) -> i32; }
trait Named: Base { fn name(self) -> str; }
struct X {}
impl Named for X { fn name(self) -> str { "x" } }
error[E0077]: `X` implements `Named` but not its supertrait `Base` --> main.nabi:4:1 | 4 | impl Named for X { fn name(self) -> str { "x" } } | ^^^^
Implement the supertrait too:
nabi
trait Base { fn id(self) -> i32; }
trait Named: Base { fn name(self) -> str; }
struct X {}
impl Base for X { fn id(self) -> i32 { 1 } }
impl Named for X { fn name(self) -> str { "x" } }
println(f"{X {}.name()} {X {}.id()}");
x 1
Related: E0069 trait bound not satisfied, E0072 impl is missing a trait item
Found a mistake? Edit this page on GitHub. Last updated