This book is designed to transform you into a true Rust expert, equipping you with the skills and knowledge to tackle intricate challenges and craft high-quality, performant code.
What you will learn:
Advanced-Data Structures in Rust: Besides data types and primary data structures, Rust supports more advanced data structures like HashMaps and Sets. Before we look into them, let's refresh our memory on the Vector data structure.
Advanced Methods, Enums, and Pattern Matching: We have seen how methods work: when there is a struct, a method must be implemented for that struct to be able to use the data in the struct. Methods are also defined for enums and traits — concepts that we will explore after now. For now, let's revise some of the constructs of method implementations in general.
Traits and Generics in Rust: In our earlier exploration of the
Result
andOption
enums, you encountered using<T, E>
and<T>
within angle brackets. These constructs are known as generics. Generics are a powerful feature in programming that allows you to write functions, types, and structures that can work with different data types while maintaining type safety and code reusability.Lifetimes in Rust: Lifetimes is a fundamentally important concept that ensures that references remain valid and prevents issues like dangling pointers or references to memory that have been deallocated. To write safe and efficient Rust code, you must understand lifetimes and how to use them. This is one of Rust's most unique trademark features.
Advanced Functions and Closures: By now, you must be good at writing functions in Rust. If you have prior programming experience, you would know that functions sometimes accept pointers as parameters. If you know functional programming, you must have heard about higher-order functions and closures. Let's take them step by step.
Concurrency and Multithreading in Rust: This chapter will explore the world of concurrency and multithreading. Concurrency allows you to handle multiple tasks simultaneously, while multithreading takes advantage of multiple CPU cores for parallel execution. Rust's strong ownership and type system help ensure safe and efficient concurrent programming.
Error Handling in Rust: This chapter will delve into Rust's intricacies. Effective error handling is a cornerstone of robust and reliable software. We'll explore the
Result
andOption
types, learn how to use thematch
and?
operators for error handling, implement custom error types using thethiserror
crate, and discover how theResult
type aids in early returns within functions. This chapter will use real-world backend engineering scenarios to illustrate each concept.File I/O and Serialization: This comprehensive chapter will explore Rust's file input/output (I/O) operations and serialization. These topics are crucial for handling data in backend applications. We'll explore how to read and write files, perform serialization and deserialization using the
serde
crate, and work with various file formats like JSON and YAML. This chapter will use practical examples from a backend engineering perspective.Milestone Project: Building a Task Management App: We'll build a task management application using Rust in this exciting milestone project. This project will encompass concepts covered in the previous chapters, including structuring your code, error handling, file I/O, and more. Following these steps, you'll create a functional task manager allowing users to add, list, and mark tasks as completed.
This intermediate-level book dives deeper into Rust's features and concepts, enabling readers to develop more complex and robust applications.
Practical examples, exercises, and a hands-on project will ensure that you build confidence and competence in intermediate Rust programming.