docs

你正在阅读 v0.1.2 的文档。Nabi 0.1.2 已不再提供支持。 最新版本:v0.1.3 →

本页尚未翻译,以下为英文原文。

#E0046: no such method or associated item

The type has no method, associated function or associated constant of this name, or none that applies to these types. Check the spelling, the use of the trait that provides it, and its bounds.

nabi
let s = "nabi";
println(s.size());
error[E0046]: no method `size` found for type `str`
  --> main.nabi:2:9
   |
 2 | println(s.size());
   |         ^^^^^^^^
   |
   = help: did you mean `len`?

Use the method the help suggests:

nabi
let s = "nabi";
println(f"{s.len()}");
4

A call r.f(x) through a field that holds a function or a callable value is also E0046: a method call never looks at fields. The help says to write (r.f)(x).

A method that exists only on another platform is also E0046, with a note that says where it exists (chapter 17). A method of a trait that is not imported is E0135.

Related: E0043 no such field, E0047 item used in the wrong form, E0135 trait of the method not in scope

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