#E0135: trait of the method not in scope
The method exists, but it comes from a trait that is not imported here, and a trait's methods are reached only while the trait is in scope. Add use path::Trait;, as the help shows, or call it as Trait::method(x, ..).
nabi
mod zoo {
pub trait Wave { fn wave(self) -> str; }
impl Wave for i32 { fn wave(self) -> str { "hi" } }
}
println(3.wave());
error[E0135]: method `wave` comes from trait `zoo::Wave`, which is not in scope --> main.nabi:6:9 | 6 | println(3.wave()); | ^^^^^^^^ | = help: add `use pkg::zoo::Wave;`
Import the trait:
nabi
use pkg::zoo::Wave;
mod zoo {
pub trait Wave { fn wave(self) -> str; }
impl Wave for i32 { fn wave(self) -> str { "hi" } }
}
println(3.wave());
hi
Related: E0046 no such method or associated item, E0030 unresolved import
Found a mistake? Edit this page on GitHub. Last updated