-
Book Overview & Buying
-
Table Of Contents
Design Patterns and Best Practices in Rust
By :
In this chapter, we'll go over why battling the borrow checker is rarely a successful tactic. We'll look at how attempting to deceive or circumvent it frequently results in complicated, unreliable code, while heeding its advice typically produces better results. We'll also look at popular strategies used by developers to get around the borrow checker's restrictions and find out why they usually lead to more issues rather than solutions.
We'll start by looking at typical strategies used to try to "defeat" the borrow checker and why they result in code that gets more complex and brittle. Next, we'll talk about why, even though it is sometimes necessary, unsafe code is typically not the solution to borrow checker problems. Lastly, we will examine how the urge to circumvent borrow checker errors by using global state and mutable statics frequently results in code that is challenging to read and maintain...