E0411: Undefined method
| Code | Category | Stability |
|---|---|---|
E0411 | Struct and enum | Permanent |
Explanation
A method call names no method available for the receiver's type. Rue resolves user-defined methods on the receiver's struct and supported built-in receiver methods, including operations on strings and slices.
Likely cause
The method name is misspelled, belongs to another receiver type, or is unavailable for this built-in receiver kind; an associated function may also have been intended. Check the receiver expression's type and the callable members that type provides.
Examples
Unknown method name
struct Point { x: i32 }
fn main() -> i32 {
let point = Point { x: 42 };
point.value()
}
Declare the method on the receiver type
struct Point {
x: i32,
fn value(self) -> i32 { self.x }
}
fn main() -> i32 {
let point = Point { x: 42 };
point.value()
}