2 An overview of Rust
This chapter covers
- Designing systems that properly utilize Rust’s ownership system
- Visualizing Rust’s lifetime system to aid in debugging
- Controlling allocations of strings for fast performance
- Enums and basic error handling
Before we can integrate a Rust library into an existing application written in another language, we first need to understand the basics of Rust programming. This chapter will guide us through a simple application to manage digital artworks for an art museum, to learn about how the Ownership system works. Ownership & Borrowing are considered by many to be some of the most challenging things for new Rust developers to learn. We’re starting with it here instead of something simpler because these are the areas where Rust differs most from other programming languages, and they’re at the core of all Rust programs. If we don’t take the time to cover these important ideas now, it will make the rest of the book far more difficult. We’re going to use an example that ties the ownership & borrowing components of Rust programs to ownership and use of digital artwork. This should make reasoning about ownership easier, and we’ll introduce tools for visualizing changes to ownership over time.