Closed
Description
Code
struct Foo {
field: u32,
}
impl Foo {
fn field(&self) -> u32 {
self.field
}
fn new() -> Foo {
Foo { field }
}
}
Current output
error[E0425]: cannot find value `field` in this scope
--> src/lib.rs:11:15
|
11 | Foo { field }
| ^^^^^ a field by this name exists in `Self`
|
help: consider using the associated function
|
11 | Foo { self.field }
| +++++
We should not suggest using self.field
inside of a struct initializer.