I am working through examples in Rust by Example.
#[derive(Debug)]
struct Point {
x: f64,
y: f64,
}
#[derive(Debug)]
struct Rectangle {
p1: Poin
The problem is that the compiler allows partial reinitialization of a struct, but the whole struct is unusable after that. This happens even if the struct contains only a single field, and even if you only try to read the field you just reinitialized.
struct Test {
f: u32,
}
fn main() {
let mut t = Test { f: 0 };
let t1 = t;
t.f = 1;
println!("{}", t.f);
}
This is discussed in issue 21232