چه کسانی این کتاب را می‌خوانند

دانشجوعلاقه‌مند یادگیری
کتابخوان حرفه‌ایلذت مطالعه
نویسندهالهام‌گیری

The Rust Programming Language (Covers Rust 2018)

Steve Klabnik, Carol Nichols, Carol Nichols

قیمت نهایی

۴۴٬۰۰۰ تومان۴۹٬۰۰۰ تومان۱۰٪ تخفیف
  • تخفیف زمان‌دار−۵٬۰۰۰ تومان

۵٬۰۰۰ تومان صرفه‌جویی نسبت به قیمت اصلی

نسخه اصلی و اورجینال

بلافاصله پس از خرید، فایل کتاب روی دستگاه شما آمادهٔ دانلود است.

تحویل فوری
پرداخت امن
ضمانت فایل
پشتیبانی

مشخصات کتاب

سال انتشار
۲۰۱۹
فرمت
PDF
زبان
انگلیسی
حجم فایل
۵٫۳ مگابایت

دربارهٔ کتاب

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 traitsUsing Rust's memory safety guarantees to build fast, safe programsTesting, error handling, and effective refactoringGenerics, smart pointers, multithreading, trait objects, and advanced pattern matchingUsing Cargo, Rust's built-in package manager, to build, test, and document your code and manage dependenciesHow best to use Rust's advanced compiler with compiler-led programming techniquesYou'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. Brief Contents......Page 3 Contents......Page 5 Foreword......Page 15 Preface......Page 17 Intro......Page 19 Installation......Page 24 Installing rustup on Linux or macOS......Page 25 Troubleshooting......Page 26 Creating a Project Directory......Page 27 Anatomy of a Rust Program......Page 28 Compiling and Running Are Separate Steps......Page 29 Hello, Cargo!......Page 30 Creating a Project with Cargo......Page 31 Building and Running a Cargo Project......Page 32 Building for Release......Page 33 Summary......Page 34 2 Guessing Game......Page 35 Processing a Guess......Page 36 Storing Values with Variables......Page 37 Handling Potential Failure with the Result Type......Page 39 Testing the First Part......Page 40 Using a Crate to Get More Functionality......Page 41 Generating a Random Number......Page 43 Comparing the Guess to the Secret Number......Page 45 Allowing Multiple Guesses with Looping......Page 48 Quitting After a Correct Guess......Page 49 Handling Invalid Input......Page 50 Summary......Page 52 3 Common Programming Concepts......Page 53 Variables and Mutability......Page 54 Shadowing......Page 56 Scalar Types......Page 58 Compound Types......Page 62 Functions......Page 65 Function Parameters......Page 66 Statements and Expressions in Function Bodies......Page 67 Functions with Return Values......Page 69 if Expressions......Page 71 Repetition with Loops......Page 76 Summary......Page 79 What Is Ownership?......Page 80 Variable Scope......Page 82 The String Type......Page 83 Memory and Allocation......Page 84 Return Values and Scope......Page 89 References and Borrowing......Page 91 Mutable References......Page 93 Dangling References......Page 95 The Slice Type......Page 96 String Slices......Page 98 Summary......Page 102 Defining and Instantiating Structs......Page 103 Using the Field Init Shorthand When Variables and Fields Have the Same Name......Page 105 Using Tuple Structs Without Named Fields to Create Different Types......Page 106 Unit-Like Structs Without Any Fields......Page 107 An Example Program Using Structs......Page 108 Refactoring with Structs: Adding More Meaning......Page 109 Adding Useful Functionality with Derived Traits......Page 110 Defining Methods......Page 112 Methods with More Parameters......Page 114 Associated Functions......Page 115 Summary......Page 116 6 Enums & Pattern Matching......Page 117 Enum Values......Page 118 The Option Enum and Its Advantages over Null Values......Page 121 The match Control Flow Operator......Page 124 Patterns That Bind to Values......Page 126 Matching with Option ......Page 127 The _ Placeholder......Page 128 Concise Control Flow with if let......Page 129 Summary......Page 130 7 Packages, Crates & Modules......Page 131 Packages and Crates......Page 132 Defining Modules to Control Scope and Privacy......Page 133 Paths for Referring to an Item in the Module Tree......Page 135 Exposing Paths with the pub Keyword......Page 137 Starting Relative Paths with super......Page 139 Making Structs and Enums Public......Page 140 Bringing Paths into Scope with the use Keyword......Page 141 Creating Idiomatic use Paths......Page 143 Re-exporting Names with pub use......Page 144 Using External Packages......Page 145 Using Nested Paths to Clean Up Large use Lists......Page 146 Separating Modules into Different Files......Page 147 Summary......Page 148 8 Common Collections......Page 150 Updating a Vector......Page 151 Reading Elements of Vectors......Page 152 Iterating over the Values in a Vector......Page 154 Using an Enum to Store Multiple Types......Page 155 Creating a New String......Page 156 Updating a String......Page 157 Indexing into Strings......Page 160 Slicing Strings......Page 161 Methods for Iterating over Strings......Page 162 Creating a New Hash Map......Page 163 Hash Maps and Ownership......Page 164 Accessing Values in a Hash Map......Page 165 Updating a Hash Map......Page 166 Summary......Page 168 9 Error Handling......Page 169 Unrecoverable Errors with panic!......Page 170 Using a panic! Backtrace......Page 171 Recoverable Errors with Result......Page 173 Matching on Different Errors......Page 176 Shortcuts for Panic on Error: unwrap and expect......Page 177 Propagating Errors......Page 178 To panic! or Not to panic!......Page 182 Cases in Which You Have More Information Than the Compiler......Page 183 Guidelines for Error Handling......Page 184 Creating Custom Types for Validation......Page 185 Summary......Page 187 10 Generic Types, Traits & Lifetimes......Page 188 Removing Duplication by Extracting a Function......Page 189 In Function Definitions......Page 191 In Struct Definitions......Page 194 In Enum Definitions......Page 195 In Method Definitions......Page 196 Performance of Code Using Generics......Page 198 Defining a Trait......Page 199 Implementing a Trait on a Type......Page 200 Default Implementations......Page 202 Traits as Parameters......Page 203 Returning Types that Implement Traits......Page 205 Fixing the largest Function with Trait Bounds......Page 206 Using Trait Bounds to Conditionally Implement Methods......Page 208 Validating References with Lifetimes......Page 209 Preventing Dangling References with Lifetimes......Page 210 The Borrow Checker......Page 211 Generic Lifetimes in Functions......Page 212 Lifetime Annotation Syntax......Page 213 Lifetime Annotations in Function Signatures......Page 214 Thinking in Terms of Lifetimes......Page 216 Lifetime Annotations in Struct Definitions......Page 217 Lifetime Elision......Page 218 Lifetime Annotations in Method Definitions......Page 220 The Static Lifetime......Page 221 Summary......Page 222 11 Automated Tests......Page 223 The Anatomy of a Test Function......Page 224 Checking Results with the assert! Macro......Page 227 Testing Equality with the assert_eq! and assert_ne! Macros......Page 230 Adding Custom Failure Messages......Page 232 Checking for Panics with should_panic......Page 234 Controlling How Tests Are Run......Page 237 Showing Function Output......Page 238 Running a Subset of Tests by Name......Page 240 Ignoring Some Tests Unless Specifically Requested......Page 242 Unit Tests......Page 243 Integration Tests......Page 244 Summary......Page 248 12 Command Line Program......Page 249 Reading the Argument Values......Page 250 Saving the Argument Values in Variables......Page 252 Reading a File......Page 253 Refactoring to Improve Modularity and Error Handling......Page 254 Separation of Concerns for Binary Projects......Page 255 Fixing the Error Handling......Page 259 Extracting Logic from main......Page 262 Splitting Code into a Library Crate......Page 264 Writing a Failing Test......Page 266 Writing Code to Pass the Test......Page 269 Writing a Failing Test for the Case-Insensitive search Function......Page 271 Implementing the search_case_insensitive Function......Page 273 Checking Where Errors Are Written......Page 276 Printing Errors to Standard Error......Page 277 Summary......Page 278 13 Iterators & Closures......Page 279 Creating an Abstraction of Behavior with Closures......Page 280 Closure Type Inference and Annotation......Page 285 Storing Closures Using Generic Parameters and the Fn Traits......Page 286 Limitations of the Cacher Implementation......Page 289 Capturing the Environment with Closures......Page 290 Processing a Series of Items with Iterators......Page 292 The Iterator Trait and the next Method......Page 293 Methods That Consume the Iterator......Page 294 Methods That Produce Other Iterators......Page 295 Using Closures That Capture Their Environment......Page 296 Creating Our Own Iterators with the Iterator Trait......Page 297 Improving Our I/O Project......Page 299 Removing a clone Using an Iterator......Page 300 Making Code Clearer with Iterator Adaptors......Page 302 Comparing Performance: Loops vs. Iterators......Page 303 Summary......Page 305 14 Cargo & Crates.io......Page 306 Customizing Builds with Release Profiles......Page 307 Making Useful Documentation Comments......Page 308 Exporting a Convenient Public API with pub use......Page 311 Adding Metadata to a New Crate......Page 315 Publishing to Crates.io......Page 316 Removing Versions from Crates.io with cargo yank......Page 317 Creating a Workspace......Page 318 Creating the Second Crate in the Workspace......Page 319 Installing Binaries from Crates.io with cargo install......Page 323 Summary......Page 324 15 Smart Pointers......Page 325 Using Box to Point to Data on the Heap......Page 326 Using a Box to Store Data on the Heap......Page 327 Enabling Recursive Types with Boxes......Page 328 Treating Smart Pointers Like Regular References with the Deref Trait......Page 331 Using Box Like a Reference......Page 332 Defining Our Own Smart Pointer......Page 333 Treating a Type Like a Reference by Implementing the Deref Trait......Page 334 Implicit Deref Coercions with Functions and Methods......Page 335 How Deref Coercion Interacts with Mutability......Page 336 Running Code on Cleanup with the Drop Trait......Page 337 Dropping a Value Early with std::mem::drop......Page 339 Rc , the Reference Counted Smart Pointer......Page 340 Using Rc to Share Data......Page 341 Cloning an Rc Increases the Reference Count......Page 343 Enforcing Borrowing Rules at Runtime with RefCell ......Page 344 Interior Mutability: A Mutable Borrow to an Immutable Value......Page 345 Having Multiple Owners of Mutable Data by Combining Rc and RefCell ......Page 351 Creating a Reference Cycle......Page 353 Preventing Reference Cycles: Turning an Rc into a Weak ......Page 355 Summary......Page 360 16 Concurrency......Page 361 Using Threads to Run Code Simultaneously......Page 362 Creating a New Thread with spawn......Page 364 Waiting for All Threads to Finish Using join Handles......Page 365 Using move Closures with Threads......Page 367 Using Message Passing to Transfer Data Between Threads......Page 369 Channels and Ownership Transference......Page 372 Sending Multiple Values and Seeing the Receiver Waiting......Page 373 Creating Multiple Producers by Cloning the Transmitter......Page 374 Shared-State Concurrency......Page 375 Using Mutexes to Allow Access to Data from One Thread at a Time......Page 376 Extensible Concurrency with the Sync and Send Traits......Page 382 Implementing Send and Sync Manually Is Unsafe......Page 383 Summary......Page 384 Characteristics of Object-Oriented Languages......Page 385 Encapsulation That Hides Implementation Details......Page 386 Inheritance as a Type System and as Code Sharing......Page 388 Defining a Trait for Common Behavior......Page 389 Implementing the Trait......Page 391 Object Safety Is Required for Trait Objects......Page 394 Implementing an Object-Oriented Design Pattern......Page 396 Defining Post and Creating a New Instance in the Draft State......Page 397 Ensuring the Content of a Draft Post Is Empty......Page 398 Requesting a Review of the Post Changes Its State......Page 399 Adding the approve Method that Changes the Behavior of content......Page 400 Trade-offs of the State Pattern......Page 403 Summary......Page 407 18 Patterns & Matching......Page 408 Conditional if let Expressions......Page 409 for Loops......Page 411 let Statements......Page 412 Function Parameters......Page 413 Refutability: Whether a Pattern Might Fail to Match......Page 414 Matching Literals......Page 415 Matching Named Variables......Page 416 Matching Ranges of Values with the ... Syntax......Page 417 Destructuring to Break Apart Values......Page 418 Ignoring Values in a Pattern......Page 422 Extra Conditionals with Match Guards......Page 426 @ Bindings......Page 428 Summary......Page 429 19 Advanced Features......Page 430 Unsafe Superpowers......Page 431 Dereferencing a Raw Pointer......Page 432 Calling an Unsafe Function or Method......Page 434 Accessing or Modifying a Mutable Static Variable......Page 438 Implementing an Unsafe Trait......Page 439 Specifying Placeholder Types in Trait Definitions with Associated Types......Page 440 Default Generic Type Parameters and Operator Overloading......Page 442 Fully Qualified Syntax for Disambiguation: Calling Methods with the Same Name......Page 444 Using Supertraits to Require One Trait’s Functionality Within Another Trait......Page 447 Using the Newtype Pattern to Implement External Traits on External Types......Page 449 Using the Newtype Pattern for Type Safety and Abstraction......Page 450 Creating Type Synonyms with Type Aliases......Page 451 The Never Type That Never Returns......Page 453 Dynamically Sized Types and the Sized Trait......Page 454 Function Pointers......Page 456 Returning Closures......Page 458 Declarative Macros with macro_rules! for General Metaprogramming......Page 459 How to Write a Custom derive Macro......Page 462 Attribute-like macros......Page 467 Summary......Page 468 20 Multithreaded Web Server......Page 469 Listening to the TCP Connection......Page 470 Reading the Request......Page 472 A Closer Look at an HTTP Request......Page 474 Writing a Response......Page 475 Returning Real HTML......Page 476 Validating the Request and Selectively Responding......Page 477 A Touch of Refactoring......Page 478 Simulating a Slow Request in the Current Server Implementation......Page 480 Improving Throughput with a Thread Pool......Page 481 Implementing the Drop Trait on ThreadPool......Page 499 Signaling to the Threads to Stop Listening for Jobs......Page 501 Summary......Page 505 Keywords Currently in Use......Page 506 Raw Identifiers......Page 508 Operators......Page 510 Non-operator Symbols......Page 512 Derivable Traits......Page 517 Development Tools......Page 521 Editions......Page 525 Index......Page 527 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 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, definitive guide to Rust, a hugely popular, community-supported programming language. This is the second edition of the improved version of the free online Rust book, so well-loved in the Rust community that it is simply referred to as "the Book". Programmers love Rust because it allows them to write powerful code efficiently, without the risk of crashes and errors common in languages like C and C++. This book will show readers how to use Rust's robust type system to keep programs memory-safe and speedy, and make the most of the Cargo package manager that brings the pieces of a program together. The reader will learn all about Rust's ownership rules, which lie at the heart of Rust's reliability and crash-resistant compiling. The Rust Programming Language covers everything from basic concepts like variable bindings, control flow, functions, and error handling, to more advanced topics, such as crates, generics, concurrency, and the nitty gritty of Rust's type system. With improved organization, hands-on features, and a more tutorial-oriented style, this version offers a vast improvement over the original. The second edition also provides an entirely new chapter on macros and an expanded chapter on crates, two key aspects of Rust that make it so popular. Readers will also find extra appendices on Rust development tools and Rust versions

قیمت نهایی

۴۴٬۰۰۰ تومان