1. Introduction
  2. Language, Standard Library, and Code Organization
  3. Code Organization
    ❱
    1. Modules and Paths
    2. Visibility
    3. use Keyword
    4. Dependencies
    5. Code Organization by Project Type and Size
  4. Standard Library
    ❱
    1. Option
    2. Result
    3. Box
    4. Clone-on-Write (Cow)
    5. AsRef
    6. Automatic Trait Derivation (Derive)
  5. Index

The Rust How-to Book

Standard Library

Option

RecipeCrates
Store Optional Values in Optionstd
Use Adapters when Working with Referencesstd
Extract the Value Contained in an Option with unwrap* and expectstd
Transform Values Contained within an Optionstd
Use Option with match, if let, or while letstd
Common Option Methodsstd
Implement the "Early Return" Pattern with the ? Operatorstd

Result

RecipeCrates
Handle Recoverable Errors with Resultstd
Retrieve or Transform Values in Resultstd
Get Reference to Values Inside a Resultstd
Result vs Optionstd

Smart Pointers

RecipeCrates
[RefCell][ex-standard_library-refcell]std
[Cell][ex-standard_library-cell]std
[OnceCell][ex-standard_library-oncecell]std

Box

RecipeCrates
Store Data on the Heap with Boxstd
Box Use Casesstd
Use Box to store Dynamically Sized Typesstd
Implement Recursive Data Structures with Boxstd
Use Box as a Smart Pointer to Owned Trait Objectsstd

Copy-On-Write (Cow)

RecipeCrates
Accept Either a Owned or Borrowed Value as the Input of a Functionstd
Convert a Cow to a borrowed or owned typestd
Efficiently Construct a Cow with intostd
Modify a Cow In-placestd
Return a Cow from a Functionstd

AsRef

RecipeCrates
Accept Arguments of Multiple Types with AsRefstd
Use as_ref to Get a Reference to the Contained Value of a Smart Pointerstd
AsRef vs. Deref vs. Borrowstd

Derive: Automatic Trait Derivation

RecipeCrates
Derive Common Traits Automaticallystd
Derive Additional Traits with derive_morederive_more