My Account Log in

1 option

Design Patterns and Best Practices in Rust.

O'Reilly Online Learning: Academic/Public Library Edition Available online

View online
Format:
Book
Author/Creator:
Williams, Evan
Contributor:
Mckay, Scott
Language:
English
Subjects (All):
Rust (Computer program language).
Physical Description:
1 online resource (450 p.)
Place of Publication:
Birmingham, England Packt Publishing 2026
Summary:
Write safer, more maintainable Rust code by identifying anti-patterns, applying idiomatic design patterns tailored to ownership, borrowing, and the type system, and learning when to adapt or avoid traditional solutions.Free with your book: DRM-free PDF version + access to Packt's next-gen Reader* Key Features Leverage traits, ownership...
Contents:
Intro
Design Patterns and Best Practices in Rust
Enhance your Rust skills by applying idiomatic approaches to real-world software design
Foreword
Contributors
About the author
About the reviewers
Join us on Discord!
Table of Contents
Preface
Who this book is for
What this book covers
To get the most out of this book
Download the example code files
Download the color images
Conventions used
Get in touch
Free benefits with your book
How to Unlock
Share your thoughts
Part 1
Thinking in Rust
1
Why Is Rust Different?
Technical requirements
Why do I need new patterns?
Working with the familiar
Experience can be misleading
Example
parsing messages in place
Hitting the wall
A sudden stop
Learning why this happens
The Rust learning curve
Learning Rust can feel very different
The uneven path
Learning to think in Rust
Thinking in code
Finding understanding
Let's build a calculator, badly!
Summary
Get this book's PDF version and more
2
Anti-Pattern: Designing for Object Orientation
Technical requirements
Why is Rust not an OO language?
Structs are not classes
Rust has a different take on polymorphism
The borrow checker prevents object patterns
Pulling it together: types are not objects
Misusing traits
Using Deref as a poor substitute for inheritance
Attacking the mess
Can Deref help us?
Using generic types to act like classes
Using enums where they don't make sense
A ""not-so-bad"" calculator
A worse calculator
The worst calculator
3
Anti-Pattern: Using Clone and Rc Everywhere
Avoiding ownership concerns
The allure of ignoring ownership
Why does ownership matter?
Cloning everything
The clone hammer
A better approach
Misusing Rc and RefCell (and friends)
The siren song of smart pointers
Simpler is better
When to use smart pointers
4
Don't Fight the Borrow Checker
Trying to defeat the borrow checker: friend or foe?
unsafe is (usually) not the answer: a dangerous shortcut
Over-using globals and mutable statics
Summary
Get this book's PDF version and more
Part 2
Replacing Traditional Design Patterns
5
Creational Patterns: Making Things
Factory Method
How does Factory Method work in Rust?
Beyond simple creation
Abstract Factory
Implementing Abstract Factory in Rust
When and when not to use Abstract Factory
Builder
Why use Builder?
Why use a specialized builder?
When not to use Builder
Singleton
Prototype
6
Structural Patterns: Connecting and Aggregating Components
Notes:
Description based upon print version of record.
Technical requirements
ISBN:
9781836209478
OCLC:
1587889348

The Penn Libraries is committed to describing library materials using current, accurate, and responsible language. If you discover outdated or inaccurate language, please fill out this feedback form to report it and suggest alternative language.

Find

Home Release notes

My Account

Shelf Request an item Bookmarks Fines and fees Settings

Guides

Using the Find catalog Using Articles+ Using your account