docs

您正在閱讀 v0.1.2 的文件。Nabi 0.1.2 已停止支援。 最新版本:v0.1.3 →

本頁尚未翻譯,以下為英文原文。

#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