docs

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

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

#E0087: ambiguous associated item

Several traits, impls or bounds give a method, associated type or constant of this name, so T::name is unclear. Name the trait: <T as Trait>::name, or call the method as Trait::name(x).

nabi
trait A { const N: i32; }
trait B { const N: i32; }
struct S {}
impl A for S { const N: i32 = 1; }
impl B for S { const N: i32 = 2; }

println(f"{S::N}");
error[E0087]: associated const `N` of `S` is ambiguous: `A` and `B` define it - name the trait (`<T as Tr>::N`)
  --> main.nabi:7:12
   |
 7 | println(f"{S::N}");
   |            ^^^^

Name the trait:

nabi
trait A { const N: i32; }
trait B { const N: i32; }
struct S {}
impl A for S { const N: i32 = 1; }
impl B for S { const N: i32 = 2; }

println(f"{<S as B>::N}");
2

Related: E0031 ambiguous name, E0075 conflicting implementations

Found a mistake? Edit this page on GitHub. Last updated