E0413: Method call on non struct
| Code | Category | Stability |
|---|---|---|
E0413 | Struct and enum | Permanent |
Explanation
A method-call expression uses a receiver whose type does not provide a matching method. User-defined methods belong to struct types; compiler-provided built-in receiver operations are resolved separately.
Likely cause
The receiver has an unexpected scalar or other non-struct type, or method syntax was used where an ordinary function or operator was intended. Check the receiver expression's type and choose an operation available for that type.
Examples
Method call on an integer
fn main() -> i32 {
let value: i32 = 42;
value.missing()
}
Use an operation defined for the value
fn main() -> i32 {
let value: i32 = 40;
value + 2
}