3 ms·
Rust's ownership/borrowing model is very close to the (often implicit) model of proper pointer handling in a large C codebase. One medium-sized codebase I've wo
by geofft 8y ago
Rust's ownership/borrowing model is very close to the (often implicit) model of proper pointer handling in a large C codebase. One medium-sized codebase I've worked with tried to be very disciplined about const pointers as a means of passing shared reference vs. ownership, with a style guide about when to use const that strongly preferred const wherever possible. I tried translating the style guide to Rust and found that's it's basically automatic once you add Rust's reference model.
Of course the big distinction is that Rust mandates it. There's lots of C code out there that happens to work fine with shared data structures that never collide in practice (or at least never collide under non-hostile input...) - see for instance every standard libc API that returns a pointer to a static buffer. Our codebase merely had a style guide, and lots of older code was less disciplined. Rust forces you to care up front about everything.