I have below code
struct Rectangle {
length: i32,
width: i32,
}
impl Default for Rectangle {
fn default() -> Self {
Rectangle {
length: 10,
width: length * 2,
}
}
}
Here I'm trying to initialize width
as 2*length
in default
. but this is giving me below compilation error.
cannot find value
length
in this scope
what could be the possible solution here?