Book description
Systems programming provides the foundation for the world's computation. Writing performance-sensitive code requires a programming language that puts programmers in control of how memory, processor time, and other system resources are used. The Rust systems programming language combines that control with a modern type system that catches broad classes of common mistakes, from memory management errors to data races between threads.
With this practical guide, experienced systems programmers will learn how to successfully bridge the gap between performance and safety using Rust. Jim Blandy, Jason Orendorff, and Leonora Tindall demonstrate how Rust's features put programmers in control over memory consumption and processor use by combining predictable performance with memory safety and trustworthy concurrency.
You'll learn:
- Rust's fundamental data types and the core concepts of ownership and borrowing
- How to write flexible, efficient code with traits and generics
- How to write fast, multithreaded code without data races
- Rust's key power tools: closures, iterators, and asynchronous programming
- Collections, strings and text, input and output, macros, unsafe code, and foreign function interfaces
This revised, updated edition covers the Rust 2021 Edition.
Publisher resources
Table of contents
- Preface
- 1. Systems Programmers Can Have Nice Things
- 2. A Tour of Rust
- 3. Fundamental Types
- 4. Ownership and Moves
- 5. References
-
6. Expressions
- An Expression Language
- Precedence and Associativity
- Blocks and Semicolons
- Declarations
- if and match
- if let
- Loops
- Control Flow in Loops
- return Expressions
- Why Rust Has loop
- Function and Method Calls
- Fields and Elements
- Reference Operators
- Arithmetic, Bitwise, Comparison, and Logical Operators
- Assignment
- Type Casts
- Closures
- Onward
- 7. Error Handling
- 8. Crates and Modules
- 9. Structs
- 10. Enums and Patterns
- 11. Traits and Generics
- 12. Operator Overloading
- 13. Utility Traits
- 14. Closures
-
15. Iterators
- The Iterator and IntoIterator Traits
- Creating Iterators
- Iterator Adapters
-
Consuming Iterators
- Simple Accumulation: count, sum, product
- max, min
- max_by, min_by
- max_by_key, min_by_key
- Comparing Item Sequences
- any and all
- position, rposition, and ExactSizeIterator
- fold and rfold
- try_fold and try_rfold
- nth, nth_back
- last
- find, rfind, and find_map
- Building Collections: collect and FromIterator
- The Extend Trait
- partition
- for_each and try_for_each
- Implementing Your Own Iterators
- 16. Collections
-
17. Strings and Text
- Some Unicode Background
- Characters (char)
-
String and str
- Creating String Values
- Simple Inspection
- Appending and Inserting Text
- Removing and Replacing Text
- Conventions for Searching and Iterating
- Patterns for Searching Text
- Searching and Replacing
- Iterating over Text
- Trimming
- Case Conversion for Strings
- Parsing Other Types from Strings
- Converting Other Types to Strings
- Borrowing as Other Text-Like Types
- Accessing Text as UTF-8
- Producing Text from UTF-8 Data
- Putting Off Allocation
- Strings as Generic Collections
- Formatting Values
- Regular Expressions
- Normalization
- 18. Input and Output
- 19. Concurrency
-
20. Asynchronous Programming
-
From Synchronous to Asynchronous
- Futures
- Async Functions and Await Expressions
- Calling Async Functions from Synchronous Code: block_on
- Spawning Async Tasks
- Async Blocks
- Building Async Functions from Async Blocks
- Spawning Async Tasks on a Thread Pool
- But Does Your Future Implement Send?
- Long Running Computations: yield_now and spawn_blocking
- Comparing Asynchronous Designs
- A Real Asynchronous HTTP Client
-
An Asynchronous Client and Server
- Error and Result Types
- The Protocol
- Taking User Input: Asynchronous Streams
- Sending Packets
- Receiving Packets: More Asynchronous Streams
- The Clientâs Main Function
- The Serverâs Main Function
- Handling Chat Connections: Async Mutexes
- The Group Table: Synchronous Mutexes
- Chat Groups: tokioâs Broadcast Channels
- Primitive Futures and Executors: When Is a Future Worth Polling Again?
- Pinning
- When Is Asynchronous Code Helpful?
-
From Synchronous to Asynchronous
- 21. Macros
- 22. Unsafe Code
- 23. Foreign Functions
- Index
- About the Authors
Product information
- Title: Programming Rust, 2nd Edition
- Author(s):
- Release date: June 2021
- Publisher(s): O'Reilly Media, Inc.
- ISBN: 9781492052548
You might also like
book
The Rust Programming Language, 2nd Edition
The Rust Programming Language, 2nd Edition is the official guide to Rust 2021: an open source …
book
Programming Rust
Rust is a new systems programming language that combines the performance and low-level control of C …
book
A Tour of C++, 2nd Edition
In Bjarne Stroustrup, the creator of C++, describes what constitutes modern C++. This concise, self-contained guide …
book
C++20 for Programmers: An Objects-Natural Approach, 3rd Edition
The professional programmer's Deitel® guide to C++20 "C++20 for Programmers builds up an intuition for modern …