After completing this book, you will have built your own LinkedList data
structure and several other small programs from along the way.
Author(s): Claus Matzinger
Edition: 1
Publisher: BPB Online
Year: 2022
Language: English
City: London
Cover Page
Title Page
Copyright Page
Dedication Page
About the Author
Acknowledgement
Preface
Errata
Table of Contents
1. Building the Basics
Structure
Objectives
Compiling Rust code
What is compilation
Memory management and dynamic versus static typing
Executing the code
Programming in Rust
Managing memory in Rust
Writing Rust code
Working with variable types
Being literal
Conclusion
Challenge
2. Controlling the Program Flow
Structure
Objectives
Making decisions with if
Using conditions
What if condition fails
Using If/Else expressions
Repetitions and repetitions with loop
Continuing and breaking with values
Enumerating with for
Breaking on conditions with while
Conclusion
Challenge
3. Organizing for Reuse
Structure
Objectives
Encapsulating behavior with functions
Parameterizing functions
Encapsulating data with structs
Getting a deeper look
Exporting and importing with modules
Aliasing types and exporting imports
Conclusion
Challenge
4. Interfacing with Code and Errors
Structure
Objectives
Using traits for fun and pleasure
Implementing traits
Using traits in functions
Creating variations with enums
Handling errors with enums
Matching patterns to extract data
Conclusion
Challenge
Further reading
5. Borrowing Ownership with Scopes
Structure
Objectives
Taking ownership of memory
Working with both kinds of memory
Borrowing memory
Working in scopes
Controlling mutability
Introducing clones
Conclusion
Challenge
6. Working with Collections
Structure
Objectives
Using sequential collections: slices and Vec
Operating the Vec
Borrowing the Vec: slices
Deriving keys from values with sets and maps
Sorting keys: trees and hashes
Using sets and maps
Iterating over any collection
Chaining iterators together
Collecting the results
Conclusion
Challenge
Further reading
7. Reading Input and Writing Output
Structure
Objectives
Reading from and writing to I/O streams
Console, networking, and file systems
Using formatted print
Configuration options for programs
Using command-line arguments
Using environment variables
Conclusion
Challenge
8. Using Crates with Cargo
Structure
Objectives
Creating crates with cargo
Writing the build manifest
Adding third-party crates
Going deeper into cargo
Customizing the build
Using workspaces for large projects
Conclusion
Challenge
Further reading
9. Testing What you Build
Structure
Objectives
Testing Rust code
Testing units
Testing integration
Benchmarking Rust code
Conclusion
Challenge
10. Documenting What You Build
Structure
Objectives
Documenting Rust code
Using sections, links, and others
Writing documentation tests
Publishing your documentation
Conclusion
Challenge
11. Generating Code with Macros
Structure
Objectives
Declarative macros
Using arguments with names and designators
Adding complexity to arguments
Exporting macros
Procedural macros
Writing function-like macros
Deriving stuff with macros
Using attributes to extend code
Conclusion
Challenge
12. Using Heap Memory Effectively
Structure
Objectives
Putting things in boxes
Boxing data
Boxing behavior
Counting references
Counting references with multi-threading
Creating mutability as required
Using locks for global mutability
Conclusion
Challenge
Further reading
13. Running Concurrent Code
Structure
Objectives
Threading with Rust
Using Send and Sync
Using alternatives
Bridging threads with channels
Conclusion
Challenge
14. Writing Async Code
Structure
Objectives
Scheduling tasks in a loop
Polling futures
Using futures-rs
Using async-std
Working asynchronously
Running blocking code
Conclusion
Challenge
15. Working with Generics
Structure
Objectives
Using Generics
Parameterizing functions
Parameterizing structs, traits, and enums
Going deeper
Using const Generics
Working with lifetimes
Conclusion
Challenge
16. Calling Unsafe and Foreign Functions
Structure
Objectives
Working with unsafe
Sharing native Rust code
Importing a shared library
Binding Rust code
Exporting as shared library
Conclusion
Further reading
Index