Effective Rust - Helion
ISBN: 9781098151362
stron: 298, Format: ebook
Data wydania: 2024-04-01
Księgarnia: Helion
Cena książki: 194,65 zł (poprzednio: 226,34 zł)
Oszczędzasz: 14% (-31,69 zł)
Rust's popularity is growing, due in part to features like memory safety, type safety, and thread safety. But these same elements can also make learning Rust a challenge, even for experienced programmers. This practical guide helps you make the transition to writing idiomatic Rust—while also making full use of Rust's type system, safety guarantees, and burgeoning ecosystem.
If you're a software engineer who has experience with an existing compiled language, or if you've struggled to convert a basic understanding of Rust syntax into working programs, this book is for you. By focusing on the conceptual differences between Rust and other compiled languages, and by providing specific recommendations that programmers can easily follow, Effective Rust will soon have you writing fluent Rust, not just badly translated C++.
- Understand the structure of Rust's type system
- Learn Rust idioms for error handling, iteration, and more
- Discover how to work with Rust's crate ecosystem
- Use Rust's type system to express your design
- Win fights with the borrow checker
- Build a robust project that takes full advantage of the Rust tooling ecosystem
Osoby które kupowały "Effective Rust", wybierały także:
- Windows Media Center. Domowe centrum rozrywki 66,67 zł, (8,00 zł -88%)
- Ruby on Rails. Ćwiczenia 18,75 zł, (3,00 zł -84%)
- Przywództwo w świecie VUCA. Jak być skutecznym liderem w niepewnym środowisku 58,64 zł, (12,90 zł -78%)
- Scrum. O zwinnym zarządzaniu projektami. Wydanie II rozszerzone 58,64 zł, (12,90 zł -78%)
- Od hierarchii do turkusu, czyli jak zarządzać w XXI wieku 58,64 zł, (12,90 zł -78%)
Spis treści
Effective Rust eBook -- spis treści
- Preface
- Who This Book Is For
- Rust Version
- Navigating This Book
- Conventions Used in This Book
- OReilly Online Learning
- How to Contact Us
- Acknowledgments
- 1. Types
- Item 1: Use the type system to express your data structures
- Fundamental Types
- Aggregate Types
- enums
- enums with Fields
- Ubiquitous enum Types
- Option<T>
- Result<T, E>
- Item 2: Use the type system to express common behavior
- Functions and Methods
- Function Pointers
- Closures
- Traits
- Trait bounds
- Trait objects
- Item 3: Prefer Option and Result transforms over explicit match expressions
- Things to Remember
- Item 4: Prefer idiomatic Error types
- The Error Trait
- Minimal Errors
- Nested Errors
- Trait Objects
- Libraries Versus Applications
- Things to Remember
- Item 5: Understand type conversions
- User-Defined Type Conversions
- Casts
- Coercion
- Item 6: Embrace the newtype pattern
- Bypassing the Orphan Rule for Traits
- Newtype Limitations
- Item 7: Use builders for complex types
- Item 8: Familiarize yourself with reference and pointer types
- Rust References
- Pointer Traits
- Fat Pointer Types
- Slices
- Trait objects
- More Pointer Traits
- Smart Pointer Types
- Item 9: Consider using iterator transforms instead of explicit loops
- Iterator Traits
- Iterator Transforms
- Iterator Consumers
- Building Collections from Result Values
- Loop Transformation
- When Explicit Is Better
- Item 1: Use the type system to express your data structures
- 2. Traits
- Item 10: Familiarize yourself with standard traits
- Common Standard Traits
- Clone
- Copy
- Default
- PartialEq and Eq
- PartialOrd and Ord
- Hash
- Debug and Display
- Standard Traits Covered Elsewhere
- Operator Overloads
- Summary
- Common Standard Traits
- Item 11: Implement the Drop trait for RAII patterns
- Item 12: Understand the trade-offs between generics and trait objects
- Generics
- Trait Objects
- Basic Comparisons
- More Trait Bounds
- Trait Object Safety
- Trade-Offs
- Item 13: Use default implementations to minimize required trait methods
- Item 10: Familiarize yourself with standard traits
- 3. Concepts
- Item 14: Understand lifetimes
- Introduction to the Stack
- Evolution of Lifetimes
- Scope of a Lifetime
- Algebra of Lifetimes
- Lifetime Elision Rules
- The static Lifetime
- Lifetimes and the Heap
- Lifetimes in Data Structures
- Anonymous Lifetimes
- Things to Remember
- Item 15: Understand the borrow checker
- Access Control
- Borrow Rules
- Owner Operations
- Winning Fights Against the Borrow Checker
- Local code refactoring
- Data structure design
- Smart pointers
- Self-referential data structures
- Things to Remember
- Item 16: Avoid writing unsafe code
- Item 17: Be wary of shared-state parallelism
- Data Races
- Data races in C++
- Data races in Rust
- Standard marker traits
- Deadlocks
- Advice
- Data Races
- Item 18: Dont panic
- Item 19: Avoid reflection
- Upcasting in Future Versions of Rust
- Item 20: Avoid the temptation to over-optimize
- Data Structures and Allocation
- Whos Afraid of the Big Bad Copy?
- References and Smart Pointers
- Item 14: Understand lifetimes
- 4. Dependencies
- Item 21: Understand what semantic versioning promises
- Semver Essentials
- Semver for Crate Authors
- Semver for Crate Users
- Discussion
- Item 22: Minimize visibility
- Visibility Syntax
- Visibility Semantics
- Item 23: Avoid wildcard imports
- Item 24: Re-export dependencies whose types appear in your API
- Item 25: Manage your dependency graph
- Version Specification
- Solving Problems with Tooling
- What to Depend On
- Things to Remember
- Item 26: Be wary of feature creep
- Conditional Compilation
- Features
- Things to Remember
- Item 21: Understand what semantic versioning promises
- 5. Tooling
- Item 27: Document public interfaces
- Tooling
- Additional Documentation Locations
- Published Crate Documentation
- What Not to Document
- Things to Remember
- Item 28: Use macros judiciously
- Declarative Macros
- Procedural Macros
- Function-like macros
- Attribute macros
- Derive macros
- When to Use Macros
- Disadvantages of Macros
- Advice
- Item 29: Listen to Clippy
- Item 30: Write more than unit tests
- Unit Tests
- Integration Tests
- Doc Tests
- Examples
- Benchmarks
- Fuzz Testing
- Testing Advice
- Things to Remember
- Item 31: Take advantage of the tooling ecosystem
- Tools to Remember
- Item 32: Set up a continuous integration (CI) system
- CI Steps
- CI Principles
- Public CI Systems
- Item 27: Document public interfaces
- 6. Beyond Standard Rust
- Item 33: Consider making library code no_std compatible
- core
- alloc
- Writing Code for no_std
- Fallible Allocation
- Things to Remember
- Item 34: Control what crosses FFI boundaries
- Invoking C Functions from Rust
- Linking logistics
- Code concerns
- Name mangling
- Accessing C Data from Rust
- Lifetimes
- Invoking Rust from C
- Things to Remember
- Invoking C Functions from Rust
- Item 35: Prefer bindgen to manual FFI mappings
- Beyond C
- Item 33: Consider making library code no_std compatible
- Afterword
- Index