Closed
Description
The following code (playground):
struct A {
banana: u8,
}
impl A {
fn new(peach: u8) -> A {
A {
banana: banana // note: banana not in scope here
}
}
}
produces the following error:
error[E0425]: cannot find value `banana` in this scope
--> src/lib.rs:8:21
|
8 | banana: banana
| ^^^^^^
| |
| `self` value is a keyword only available in methods with `self` parameter
| help: try: `self.banana`
First, help
is wrong, because this is a static method and self is not available in scope. Second it is not clear why a line above help
is talking about self
at all.