2 Useful Rust Patterns for Web Programming
Before you begin: Join our book community on Discord
Give your feedback straight to the author himself and chat to other early readers on our Discord server (find the "rust-web-programming-3e" channel under EARLY ACCESS SUBSCRIPTION).
Knowing the syntax and borrowing rules of Rust can get us building programs. However, unlike dynamic programming languages, Rust has a strict type system. If you do not know how to get creative with traits, this can lead to you creating a lot of excessive code to solve problems. In this chapter, we will cover how to enforce certain parameter checks with traits increasing the flexibility of the parameters of functions accepting structs. We will also explore metaprogramming with macros to reduce the amount of repetitive code we have to write. These macros will also enable us to simplify and effectively communicate with other developers what our code does. We will also utilize...