-
Book Overview & Buying
-
Table Of Contents
Design Patterns and Best Practices in Rust
By :
In this section, we will discuss how developers often try to sidestep Rust's ownership system entirely rather than working with it. We'll look at why this method produces designs that are problematic and investigate different options that support Rust's ownership paradigm.
The ownership structure of Rust may seem like an extra burden to developers when they first come across it. Rust's stringent guidelines regarding who owns what and when appear constrictive and annoying to someone from languages where data may be freely exchanged and altered. Although the fundamental rules themselves are straightforward – each value has exactly one owner, borrowing allows temporary access without taking ownership, and mutable borrows are exclusive – it's tempting to look for ways to ignore these rules entirely.
Let's look at how this manifests in our calculator project. We want to...