this post was submitted on 27 Apr 2024
1 points (100.0% liked)
Rust
5999 readers
4 users here now
Welcome to the Rust community! This is a place to discuss about the Rust programming language.
Wormhole
Credits
- The icon is a modified version of the official rust logo (changing the colors to a gradient and black background)
founded 1 year ago
MODERATORS
you are viewing a single comment's thread
view the rest of the comments
view the rest of the comments
The borrow checker is useful for a lot more than memory safety. This is something I have been repeating for years, but unfortunately people new to the language don't understand it yet.
E.g. Rust is the only mainstream language where it isn't possible to read from a file handle after it's been closed. There are numerous other common benefits of it that apply to general purpose programming, like not being able to mutate a collection while you're iterating over it.
It's a very common practice in Rust to enforce domain invariants using Rust's ownership rules, and those things cannot be enforced at compile time in other languages that don't have ownership.
The borrow checker is also usually pretty easy to get around with just a bit of experience in Rust.