> The complexity of Rust's ownership model is not added to an otherwise simple program, it is merely the compiler being extremely pedantic about your code obeying rules it had to obey anyway. Not exactly. I remember when I learned Rust a few years ago (so maybe things are different today), sometimes the compiler didn't let me do things that should have been perfectly fine things to do. This forced me to write the cod…
Why does that require a macro?
``` struct S { x:X, y:Y }
fn do_with_y (y:&mut Y) {} fn do_with_s (y:&mut S) {}
fn main_program (mut s: S) { do_with_s(&mut s); do_with_y(&s.y); /* ... */ } ```
I prefer seeing code like this rather than wrapping it in abstractions and macros/helpers because it's not particularly verbose and very clear where the borrowing happens ; you'd see the same in C++ or C, to be honest.