Rust for Rustaceans: Idiomatic Programming for Experienced Developers

Оглавление⌄
Title Page....10 Copyright....11 About the Author....12 Foreword....13 Preface....15 Acknowledgments....17 Introduction....19 Chapter 1: Foundations....23 Talking About Memory....24 Memory Terminology....24 Variables in Depth....25 Memory Regions....28 Ownership....31 Borrowing and Lifetimes....33 Shared References....34 Mutable References....34 Interior Mutability....37 Lifetimes....38 Summary....44 Chapter 2: Types....46 Types in Memory....46 Alignment....47 Layout....48 Complex Types....51 Dynamically Sized Types and Wide Pointers....51 Traits and Trait Bounds....52 Compilation and Dispatch....53 Generic Traits....57 Coherence and the Orphan Rule....58 Trait Bounds....62 Marker Traits....64 Existential Types....66 Summary....67 Chapter 3: Designing Interfaces....68 Unsurprising....69 Naming Practices....69 Common Traits for Types....70 Ergonomic Trait Implementations....72 Wrapper Types....73 Flexible....74 Generic Arguments....75 Object Safety....77 Borrowed vs. Owned....78 Fallible and Blocking Destructors....79 Obvious....81 Documentation....82 Type System Guidance....83 Constrained....85 Type Modifications....86 Trait Implementations....87 Hidden Contracts....89 Summary....92 Chapter 4: Error Handling....94 Representing Errors....94 Enumeration....95 Opaque Errors....97 Special Error Cases....99 Propagating Errors....101 Summary....104 Chapter 5: Project Structure....105 Features....105 Defining and Including Features....106 Using Features in Your Crate....108 Workspaces....109 Project Configuration....112 Crate Metadata....112 Build Configuration....113 Conditional Compilation....119 Versioning....123 Minimum Supported Rust Version....123 Minimal Dependency Versions....125 Changelogs....126 Unreleased Versions....127 Summary....128 Chapter 6: Testing....129 Rust Testing Mechanisms....130 The Test Harness....130 #[cfg(test)]....132 Doctests....135 Additional Testing Tools....138 Linting....138 Test Generation....139 Test Augmentation....142 Performance Testing....144 Summary....149 Chapter 7: Macros....150 Declarative Macros....151 When to Use Them....151 How They Work....154 How to Write Declarative Macros....156 Procedural Macros....161 Types of Procedural Macros....161 The Cost of Procedural Macros....163 So You Think You Want a Macro....163 How Do They Work?....166 Summary....169 Chapter 8: Asynchronous Programming....170 What’s the Deal with Asynchrony?....171 Synchronous Interfaces....171 Multithreading....172 Asynchronous Interfaces....174 Standardized Polling....175 Ergonomic Futures....176 async/await....179 Pin and Unpin....183 Going to Sleep....191 Waking Up....191 Fulfilling the Poll Contract....193 Waking Is a Misnomer....195 Tasks and Subexecutors....196 Tying It All Together with spawn....198 Summary....201 Chapter 9: Unsafe Code....202 The unsafe Keyword....203 Great Power....205 Juggling Raw Pointers....206 Calling Unsafe Functions....210 Implementing Unsafe Traits....214 Great Responsibility....218 What Can Go Wrong?....219 Validity....220 Panics....224 Casting....226 The Drop Check....228 Coping with Fear....230 Manage Unsafe Boundaries....231 Read and Write Documentation....232 Check Your Work....233 Summary....235 Chapter 10: Concurrency (and Parallelism)....236 The Trouble with Concurrency....237 Correctness....237 Performance....238 Concurrency Models....242 Shared Memory....242 Worker Pools....243 Actors....245 Asynchrony and Parallelism....246 Lower-Level Concurrency....248 Memory Operations....249 Atomic Types....250 Memory Ordering....251 Compare and Exchange....259 The Fetch Methods....262 Sane Concurrency....264 Start Simple....264 Write Stress Tests....265 Use Concurrency Testing Tools....265 Summary....268 Chapter 11: Foreign Function Interfaces....270 Crossing Boundaries with extern....271 Symbols....271 Calling Conventions....277 Types Across Language Boundaries....279 Type Matching....280 Allocations....283 Callbacks....285 Safety....285 bindgen and Build Scripts....289 Summary....292 Chapter 12: Rust Without the Standard Library....293 Opting Out of the Standard Library....294 Dynamic Memory Allocation....296 The Rust Runtime....298 The Panic Handler....299 Program Initialization....299 The Out-of-Memory Handler....300 Low-Level Memory Accesses....301 Misuse-Resistant Hardware Abstraction....303 Cross-Compilation....305 Summary....307 Chapter 13: The Rust Ecosystem....309 What’s Out There?....309 Tools....310 Libraries....311 Rust Tooling....315 The Standard Library....318 Patterns in the Wild....323 Index Pointers....323 Drop Guards....324 Extension Traits....326 Crate Preludes....326 Staying Up to Date....328 What Next?....330 Learn by Watching....330 Learn by Doing....332 Learn by Reading....333 Learn by Teaching....335 Summary....336 Index....337
Описание
В этом материале разберём тему: rust.
It covers everything you need to build and maintain larger code bases, write powerful and flexible applications and libraries, and confidently expand the scope and complexity of your projects.Author Jon Gjengset takes you deep into the Rust programming language, dissecting core topics like ownership, traits, concurrency, and unsafe code. For developers who’ve mastered the basics, this book is the next step on your way to professional-level programming in Rust. You’ll explore key concepts like type layout and trait coherence, delve into the inner workings of concurrent programming and asynchrony with async/await, and take a tour of the world of no_std programming. Gjengset also provides expert guidance on API design, testing strategies, and error handling, and will help develop your understanding of foreign function interfaces, object safety, procedural macros, and much more.
You'll Learn:How to design reliable, idiomatic, and ergonomic Rust programs based on best principlesEffective use of declarative and procedural macros, and the difference between themHow asynchrony works in Rust – all the way from the Pin and Waker types used in manual implementations of Futures, to how async/await saves you from thinking about most of those wordsWhat it means for code to be unsafe, and best practices for writing and interacting with unsafe functions and traitsHow to organize and configure more complex Rust projects so that they integrate nicely with the rest of the ecosystemHow to write Rust code that can interoperate with non-Rust libraries and systems, or run in constrained and embedded environmentsBrimming with practical, pragmatic insights that you can immediately apply, Rust for Rustaceans helps you do more with Rust, while also teaching you its underlying mechanisms.
На этом основные моменты по теме закрыты.
Поделиться
Частые вопросы
Можно ли скачать «Rust for Rustaceans: Idiomatic Programming for Experienced Developers» бесплатно?
Да, «Rust for Rustaceans: Idiomatic Programming for Experienced Developers» доступна для бесплатного скачивания на нашем сайте в формате PDF. Ссылка на файл находится на этой странице.
В каком формате и какого размера файл?
Книга предоставляется в формате PDF, размер файла 1,4 МБ.
Кто автор и когда вышла книга?
автор — Gjengset Jon, издательство No Starch Press, Inc., год выпуска 2022, 363 страниц.
О чём книга «Rust for Rustaceans: Idiomatic Programming for Experienced Developers»?
For developers who’ve mastered the basics, this book is the next step on your way to professional-level programming in Rust.