ENGLISH

The Rust Programming Language (Covers Rust 2018)

Book information

Publisher
No Starch Press
Year
2019
ISBN
1718500440, 9781718500440
Language
english
Format
PDF
Filesize
5 MB (5272499 bytes)
Pages
560\889
Time added
2020-07-19 17:08:42

Description

The official book on the Rust programming language, written by the Rust development team at the Mozilla Foundation, fully updated for Rust 2018. The Rust Programming Language is the official book on Rust: an open source systems programming language that helps you write faster, more reliable software. Rust offers control over low-level details (such as memory usage) in combination with high-level ergonomics, eliminating the hassle traditionally associated with low-level languages. The authors of The Rust Programming Language, members of the Rust Core Team, share their knowledge and experience to show you how to take full advantage of Rust's features--from installation to creating robust and scalable programs. You'll begin with basics like creating functions, choosing data types, and binding variables and then move on to more advanced concepts, such as:   •  Ownership and borrowing, lifetimes, and traits   •  Using Rust's memory safety guarantees to build fast, safe programs   •  Testing, error handling, and effective refactoring   •  Generics, smart pointers, multithreading, trait objects, and advanced pattern matching   •  Using Cargo, Rust's built-in package manager, to build, test, and document your code and manage dependencies   •  How best to use Rust's advanced compiler with compiler-led programming techniques You'll find plenty of code examples throughout the book, as well as three chapters dedicated to building complete projects to test your learning: a number guessing game, a Rust implementation of a command line tool, and a multithreaded server. New to this edition: An extended section on Rust macros, an expanded chapter on modules, and appendixes on Rust development tools and editions. Title Page Copyright Page About the Authors Brief Contents Contents in Detail FOREWORD by Nicholas Matsakis and Aaron Turon PREFACE ACKNOWLEDGMENTS INTRODUCTION Who Rust Is For Who This Book Is For How to Use This Book Resources and How to Contribute to This Book 1 GETTING STARTED Installation Command Line Notation Hello, World! Hello, Cargo! Summary 2 PROGRAMMING A GUESSING GAME Setting Up a New Project Processing a Guess Generating a Secret Number Comparing the Guess to the Secret Number Allowing Multiple Guesses with Looping Summary 3 COMMON PROGRAMMING CONCEPTS Variables and Mutability Data Types Functions Comments Control Flow Summary 4 UNDERSTANDING OWNERSHIP What Is Ownership? References and Borrowing The Slice Type Summary 5 USING STRUCTS TO STRUCTURE RELATED DATA Defining and Instantiating Structs An Example Program Using Structs Method Syntax Summary 6 ENUMS AND PATTERN MATCHING Defining an Enum The match Control Flow Operator Concise Control Flow with if let Summary 7 MANAGING GROWING PROJECTS WITH PACKAGES, CRATES, AND MODULES Packages and Crates Defining Modules to Control Scope and Privacy Paths for Referring to an Item in the Module Tree Bringing Paths into Scope with the use Keyword Separating Modules into Different Files Summary 8 COMMON COLLECTIONS Storing Lists of Values with Vectors Storing UTF-8 Encoded Text with Strings Storing Keys with Associated Values in Hash Maps Summary 9 ERROR HANDLING Unrecoverable Errors with panic! Recoverable Errors with Result To panic! or Not to panic! Summary 10 GENERIC TYPES, TRAITS, AND LIFETIMES Removing Duplication by Extracting a Function Generic Data Types Traits: Defining Shared Behavior Validating References with Lifetimes Generic Type Parameters, Trait Bounds, and Lifetimes Together Summary 11 WRITING AUTOMATED TESTS How to Write Tests Controlling How Tests Are Run Test Organization Summary 12 AN I/O PROJECT: BUILDING A COMMAND LINE PROGRAM Accepting Command Line Arguments Reading a File Refactoring to Improve Modularity and Error Handling Developing the Library’s Functionality with Test-Driven Development Working with Environment Variables Writing Error Messages to Standard Error Instead of Standard Output Summary 13 FUNCTIONAL LANGUAGE FEATURES: ITERATORS AND CLOSURES Closures: Anonymous Functions That Can Capture Their Environment Processing a Series of Items with Iterators Improving Our I/O Project Comparing Performance: Loops vs. Iterators Summary 14 MORE ABOUT CARGO AND CRATES.IO Customizing Builds with Release Profiles Publishing a Crate to Crates.io Cargo Workspaces Installing Binaries from Crates.io with cargo install Extending Cargo with Custom Commands Summary 15 SMART POINTERS Using Box to Point to Data on the Heap Treating Smart Pointers Like Regular References with the Deref Trait Running Code on Cleanup with the Drop Trait Rc, the Reference Counted Smart Pointer RefCell and the Interior Mutability Pattern Reference Cycles Can Leak Memory Summary 16 FEARLESS CONCURRENCY Using Threads to Run Code Simultaneously Using Message Passing to Transfer Data Between Threads Shared-State Concurrency Extensible Concurrency with the Sync and Send Traits Summary 17 OBJECT-ORIENTED PROGRAMMING FEATURES OF RUST Characteristics of Object-Oriented Languages Using Trait Objects That Allow for Values of Different Types Implementing an Object-Oriented Design Pattern Summary 18 PATTERNS AND MATCHING All the Places Patterns Can Be Used Refutability: Whether a Pattern Might Fail to Match Pattern Syntax Summary 19 ADVANCED FEATURES Unsafe Rust Advanced Traits Advanced Types Advanced Functions and Closures Macros Summary 20 FINAL PROJECT: BUILDING A MULTITHREADED WEB SERVER Building a Single-Threaded Web Server Turning Our Single-Threaded Server into a Multithreaded Server Graceful Shutdown and Cleanup Summary A KEYWORDS Keywords Currently in Use Keywords Reserved for Future Use Raw Identifiers B OPERATORS AND SYMBOLS Operators Non-operator Symbols C DERIVABLE TRAITS Debug for Programmer Output PartialEq and Eq for Equality Comparisons PartialOrd and Ord for Ordering Comparisons Clone and Copy for Duplicating Values Hash for Mapping a Value to a Value of Fixed Size Default for Default Values D USEFUL DEVELOPMENT TOOLS Automatic Formatting with rustfmt Fix Your Code with rustfix More Lints with Clippy IDE Integration Using the Rust Language Server E EDITIONS INDEX

Similar books