<!-- Keep first page as index.md to avoid giving it two names. -->

[Welcome to Comprehensive Rust 🦀](index.md)

- [Running the Course](running-the-course.md)
  - [Course Structure](running-the-course/course-structure.md)
  - [Keyboard Shortcuts](running-the-course/keyboard-shortcuts.md)
  - [Translations](running-the-course/translations.md)
- [Using Cargo](cargo.md)
  - [Rust Ecosystem](cargo/rust-ecosystem.md)
  - [Code Samples](cargo/code-samples.md)
  - [Running Cargo Locally](cargo/running-locally.md)

---

# Day 1: Morning

- [Welcome](welcome-day-1.md)
- [Hello, World](hello-world.md)
  - [What is Rust?](hello-world/what-is-rust.md)
  - [Benefits of Rust](hello-world/benefits.md)
  - [Playground](hello-world/playground.md)
- [Types and Values](types-and-values.md)
  - [Hello, World](types-and-values/hello-world.md)
  - [Variables](types-and-values/variables.md)
  - [Values](types-and-values/values.md)
  - [Arithmetic](types-and-values/arithmetic.md)
  - [Type Inference](types-and-values/inference.md)
  - [Exercise: Fibonacci](types-and-values/exercise.md)
    - [Solution](types-and-values/solution.md)
- [Control Flow Basics](control-flow-basics.md)
  - [Blocks and Scopes](control-flow-basics/blocks-and-scopes.md)
  - [`if` Expressions](control-flow-basics/if.md)
  - [`match` Expressions](control-flow-basics/match.md)
  - [Loops](control-flow-basics/loops.md)
    - [`for`](control-flow-basics/loops/for.md)
    - [`loop`](control-flow-basics/loops/loop.md)
  - [`break` and `continue`](control-flow-basics/break-continue.md)
    - [Labels](control-flow-basics/break-continue/labels.md)
  - [Functions](control-flow-basics/functions.md)
  - [Macros](control-flow-basics/macros.md)
  - [Exercise: Collatz Sequence](control-flow-basics/exercise.md)
    - [Solution](control-flow-basics/solution.md)

# Day 1: Afternoon

- [Welcome](welcome-day-1-afternoon.md)
- [Tuples and Arrays](tuples-and-arrays.md)
  - [Arrays](tuples-and-arrays/arrays.md)
  - [Tuples](tuples-and-arrays/tuples.md)
  - [Array Iteration](tuples-and-arrays/iteration.md)
  - [Patterns and Destructuring](tuples-and-arrays/destructuring.md)
  - [Exercise: Nested Arrays](tuples-and-arrays/exercise.md)
    - [Solution](tuples-and-arrays/solution.md)
- [References](references.md)
  - [Shared References](references/shared.md)
  - [Exclusive References](references/exclusive.md)
  - [Slices](references/slices.md)
  - [Strings](references/strings.md)
  - [Reference Validity](references/dangling.md)
  - [Exercise: Geometry](references/exercise.md)
    - [Solution](references/solution.md)
- [User-Defined Types](user-defined-types.md)
  - [Named Structs](user-defined-types/named-structs.md)
  - [Tuple Structs](user-defined-types/tuple-structs.md)
  - [Enums](user-defined-types/enums.md)
  - [Type Aliases](user-defined-types/aliases.md)
  - [Const](user-defined-types/const.md)
  - [Static](user-defined-types/static.md)
  - [Exercise: Elevator Events](user-defined-types/exercise.md)
    - [Solution](user-defined-types/solution.md)

---

# Day 2: Morning

- [Welcome](welcome-day-2.md)
- [Pattern Matching](pattern-matching.md)
  - [Irrefutable Patterns](pattern-matching/infallible.md)
  - [Matching Values](pattern-matching/match.md)
  - [Destructuring Structs](pattern-matching/destructuring-structs.md)
  - [Destructuring Enums](pattern-matching/destructuring-enums.md)
  - [Let Control Flow](pattern-matching/let-control-flow.md)
    - [`if let` Expressions](pattern-matching/let-control-flow/if-let.md)
    - [`while let` Statements](pattern-matching/let-control-flow/while-let.md)
    - [`let else`](pattern-matching/let-control-flow/let-else.md)
  - [Exercise: Expression Evaluation](pattern-matching/exercise.md)
    - [Solution](pattern-matching/solution.md)
- [Methods and Traits](methods-and-traits.md)
  - [Methods](methods-and-traits/methods.md)
  - [Traits](methods-and-traits/traits.md)
    - [Implementing Traits](methods-and-traits/traits/implementing.md)
    - [Supertraits](methods-and-traits/traits/supertraits.md)
    - [Associated Types](methods-and-traits/traits/associated-types.md)
  - [Deriving](methods-and-traits/deriving.md)
  - [Exercise: Generic Logger](methods-and-traits/exercise.md)
    - [Solution](methods-and-traits/solution.md)
- [Generics](generics.md)
  - [Generic Functions](generics/generic-functions.md)
  - [Trait Bounds](generics/trait-bounds.md)
  - [Generic Data Types](generics/generic-data.md)
  - [Generic Traits](generics/generic-traits.md)
  - [`impl Trait`](generics/impl-trait.md)
  - [`dyn Trait`](generics/dyn-trait.md)
  - [Exercise: Generic `min`](generics/exercise.md)
    - [Solution](generics/solution.md)

# Day 2: Afternoon

- [Welcome](welcome-day-2-afternoon.md)
- [Closures](closures.md)
  - [Closure Syntax](closures/syntax.md)
  - [Capturing](closures/capturing.md)
  - [Closure Traits](closures/traits.md)
  - [Exercise: Log Filter](closures/exercise.md)
    - [Solution](closures/solution.md)
- [Standard Library Types](std-types.md)
  - [Standard Library](std-types/std.md)
  - [Documentation](std-types/docs.md)
  - [`Option`](std-types/option.md)
  - [`Result`](std-types/result.md)
  - [`String`](std-types/string.md)
  - [`Vec`](std-types/vec.md)
  - [`HashMap`](std-types/hashmap.md)
  - [Exercise: Counter](std-types/exercise.md)
    - [Solution](std-types/solution.md)
- [Standard Library Traits](std-traits.md)
  - [Comparisons](std-traits/comparisons.md)
  - [Operators](std-traits/operators.md)
  - [`From` and `Into`](std-traits/from-and-into.md)
  - [Casting](std-traits/casting.md)
  - [`Read` and `Write`](std-traits/read-and-write.md)
  - [`Default`, struct update syntax](std-traits/default.md)
  - [Exercise: ROT13](std-traits/exercise.md)
    - [Solution](std-traits/solution.md)

---

# Day 3: Morning

- [Welcome](welcome-day-3.md)
- [Memory Management](memory-management.md)
  - [Review of Program Memory](memory-management/review.md)
  - [Approaches to Memory Management](memory-management/approaches.md)
  - [Ownership](memory-management/ownership.md)
  - [Move Semantics](memory-management/move.md)
  - [`Clone`](memory-management/clone.md)
  - [Copy Types](memory-management/copy-types.md)
  - [`Drop`](memory-management/drop.md)
  - [Exercise: Builder Type](memory-management/exercise.md)
    - [Solution](memory-management/solution.md)
- [Smart Pointers](smart-pointers.md)
  - [`Box<T>`](smart-pointers/box.md)
  - [`Rc`](smart-pointers/rc.md)
  - [Owned Trait Objects](smart-pointers/trait-objects.md)
  - [Exercise: Binary Tree](smart-pointers/exercise.md)
    - [Solution](smart-pointers/solution.md)

# Day 3: Afternoon

- [Welcome](welcome-day-3-afternoon.md)
- [Borrowing](borrowing.md)
  - [Borrowing a Value](borrowing/shared.md)
  - [Borrow Checking](borrowing/borrowck.md)
  - [Borrow Errors](borrowing/examples.md)
  - [Interior Mutability](borrowing/interior-mutability.md)
    - [`Cell`](borrowing/interior-mutability/cell.md)
    - [`RefCell`](borrowing/interior-mutability/refcell.md)
  - [Exercise: Wizard's Inventory](borrowing/exercise.md)
    - [Solution](borrowing/solution.md)
- [Lifetimes](lifetimes.md)
  - [Borrowing and Functions](lifetimes/simple-borrows.md)
  - [Returning Borrows](lifetimes/returning-borrows.md)
  - [Multiple Borrows](lifetimes/multiple-borrows.md)
  - [Borrow Both](lifetimes/borrow-both.md)
  - [Borrow One](lifetimes/borrow-one.md)
  - [Lifetime Elision](lifetimes/lifetime-elision.md)
  - [Lifetimes in Data Structures](lifetimes/struct-lifetimes.md)
  - [Exercise: Protobuf Parsing](lifetimes/exercise.md)
    - [Solution](lifetimes/solution.md)

---

# Day 4: Morning

- [Welcome](welcome-day-4.md)
- [Iterators](iterators.md)
  - [Motivation](iterators/motivation.md)
  - [`Iterator` Trait](iterators/iterator.md)
  - [`Iterator` Helper Methods](iterators/helpers.md)
  - [`collect`](iterators/collect.md)
  - [`IntoIterator`](iterators/intoiterator.md)
  - [Exercise: Iterator Method Chaining](iterators/exercise.md)
    - [Solution](iterators/solution.md)
- [Modules](modules.md)
  - [Modules](modules/modules.md)
  - [Filesystem Hierarchy](modules/filesystem.md)
  - [Visibility](modules/visibility.md)
  - [Encapsulation](modules/encapsulation.md)
  - [`use`, `super`, `self`](modules/paths.md)
  - [Exercise: Modules for a GUI Library](modules/exercise.md)
    - [Solution](modules/solution.md)
- [Testing](testing.md)
  - [Unit Tests](testing/unit-tests.md)
  - [Other Types of Tests](testing/other.md)
  - [Compiler Lints and Clippy](testing/lints.md)
  - [Exercise: Luhn Algorithm](testing/exercise.md)
    - [Solution](testing/solution.md)

# Day 4: Afternoon

- [Welcome](welcome-day-4-afternoon.md)
- [Error Handling](error-handling.md)
  - [Panics](error-handling/panics.md)
  - [`Result`](error-handling/result.md)
  - [Try Operator](error-handling/try.md)
  - [Try Conversions](error-handling/try-conversions.md)
  - [`Error` Trait](error-handling/error.md)
  - [`thiserror`](error-handling/thiserror.md)
  - [`anyhow`](error-handling/anyhow.md)
  - [Exercise: Rewriting with `Result`](error-handling/exercise.md)
    - [Solution](error-handling/solution.md)
- [Unsafe Rust](unsafe-rust.md)
  - [Unsafe](unsafe-rust/unsafe.md)
  - [Dereferencing Raw Pointers](unsafe-rust/dereferencing.md)
  - [Mutable Static Variables](unsafe-rust/mutable-static.md)
  - [Unions](unsafe-rust/unions.md)
  - [Unsafe Functions](unsafe-rust/unsafe-functions.md)
    - [Unsafe Rust Functions](unsafe-rust/unsafe-functions/rust.md)
    - [Unsafe External Functions](unsafe-rust/unsafe-functions/extern-c.md)
    - [Calling Unsafe Functions](unsafe-rust/unsafe-functions/calling.md)
  - [Unsafe Traits](unsafe-rust/unsafe-traits.md)
  - [Exercise: FFI Wrapper](unsafe-rust/exercise.md)
    - [Solution](unsafe-rust/solution.md)

---

# Android

- [Welcome](android.md)
- [Setup](android/setup.md)
- [Build Rules](android/build-rules.md)
  - [Binary](android/build-rules/binary.md)
  - [Library](android/build-rules/library.md)
- [AIDL](android/aidl.md)
  - [Birthday Service Tutorial](android/aidl/birthday-service.md)
    - [Interface](android/aidl/example-service/interface.md)
    - [Service API](android/aidl/example-service/service-bindings.md)
    - [Service](android/aidl/example-service/service.md)
    - [Server](android/aidl/example-service/server.md)
    - [Deploy](android/aidl/example-service/deploy.md)
    - [Client](android/aidl/example-service/client.md)
    - [Changing API](android/aidl/example-service/changing-definition.md)
    - [Updating Implementations](android/aidl/example-service/changing-implementation.md)
  - [AIDL Types](android/aidl/types.md)
    - [Primitive Types](android/aidl/types/primitives.md)
    - [Array Types](android/aidl/types/arrays.md)
    - [Sending Objects](android/aidl/types/objects.md)
    - [Parcelables](android/aidl/types/parcelables.md)
    - [Sending Files](android/aidl/types/file-descriptor.md)
- [Testing](android/testing.md)
  - [GoogleTest](android/testing/googletest.md)
  - [Mocking](android/testing/mocking.md)
- [Logging](android/logging.md)
- [Interoperability](android/interoperability.md)
  - [With C](android/interoperability/with-c.md)
    - [A Simple C Library](android/interoperability/with-c/c-library.md)
    - [Bindgen](android/interoperability/with-c/bindgen.md)
    - [Running Our Binary](android/interoperability/with-c/run-our-binary.md)
    - [A Simple Rust Library](android/interoperability/with-c/rust-library.md)
    - [Calling Rust from C](android/interoperability/with-c/rust.md)
  - [With C++](android/interoperability/cpp.md)
    - [The Bridge Module](android/interoperability/cpp/bridge.md)
    - [Rust Bridge](android/interoperability/cpp/rust-bridge.md)
    - [Generated C++](android/interoperability/cpp/generated-cpp.md)
    - [C++ Bridge](android/interoperability/cpp/cpp-bridge.md)
    - [Shared Types](android/interoperability/cpp/shared-types.md)
    - [Shared Enums](android/interoperability/cpp/shared-enums.md)
    - [Rust Error Handling](android/interoperability/cpp/rust-result.md)
    - [C++ Error Handling](android/interoperability/cpp/cpp-exception.md)
    - [Additional Types](android/interoperability/cpp/type-mapping.md)
    - [Building for Android: Genrules](android/interoperability/cpp/android-cpp-genrules.md)
    - [Building for Android: C++](android/interoperability/cpp/android-build-cpp.md)
    - [Building for Android: Rust](android/interoperability/cpp/android-build-rust.md)
  - [With Java](android/interoperability/java.md)

---

# Chromium

- [Welcome](chromium.md)
- [Setup](chromium/setup.md)
- [Comparing Chromium and Cargo Ecosystems](chromium/cargo.md)
- [Policy](chromium/policy.md)
- [Build Rules](chromium/build-rules.md)
  - [Unsafe Code](chromium/build-rules/unsafe.md)
  - [Depending on Rust Code from Chromium C++](chromium/build-rules/depending.md)
  - [Visual Studio Code](chromium/build-rules/vscode.md)
  - [Exercise](exercises/chromium/build-rules.md)
- [Testing](chromium/testing.md)
  - [`rust_gtest_interop` Library](chromium/testing/rust-gtest-interop.md)
  - [GN Rules for Rust Tests](chromium/testing/build-gn.md)
  - [`chromium::import!` Macro](chromium/testing/chromium-import-macro.md)
  - [Exercise](exercises/chromium/testing.md)
- [Interoperability with C++](chromium/interoperability-with-cpp.md)
  - [Example Bindings](chromium/interoperability-with-cpp/example-bindings.md)
  - [Limitations of CXX](chromium/interoperability-with-cpp/limitations-of-cxx.md)
  - [CXX Error Handling](chromium/interoperability-with-cpp/error-handling.md)
    - [Error Handling: QR Example](chromium/interoperability-with-cpp/error-handling-qr.md)
    - [Error Handling: PNG Example](chromium/interoperability-with-cpp/error-handling-png.md)
  - [Using CXX in Chromium](chromium/interoperability-with-cpp/using-cxx-in-chromium.md)
  - [Exercise](exercises/chromium/interoperability-with-cpp.md)
- [Adding Third Party Crates](chromium/adding-third-party-crates.md)
  - [Configuring Cargo.toml](chromium/adding-third-party-crates/configuring-cargo-toml.md)
  - [Configuring `gnrt_config.toml`](chromium/adding-third-party-crates/configuring-gnrt-config-toml.md)
  - [Downloading Crates](chromium/adding-third-party-crates/downloading-crates.md)
  - [Generating `gn` Build Rules](chromium/adding-third-party-crates/generating-gn-build-rules.md)
  - [Resolving Problems](chromium/adding-third-party-crates/resolving-problems.md)
    - [Build Scripts Which Generate Code](chromium/adding-third-party-crates/resolving-problems/build-scripts-which-generate-code.md)
    - [Build Scripts Which Build C++ or Take Arbitrary Actions](chromium/adding-third-party-crates/resolving-problems/build-scripts-which-take-arbitrary-actions.md)
  - [Depending on a Crate](chromium/adding-third-party-crates/depending-on-a-crate.md)
  - [Reviews and Audits](chromium/adding-third-party-crates/reviews-and-audits.md)
  - [Checking into Chromium Source Code](chromium/adding-third-party-crates/checking-in.md)
  - [Keeping Crates Up to Date](chromium/adding-third-party-crates/keeping-up-to-date.md)
  - [Exercise](exercises/chromium/third-party.md)
- [Bringing It Together - Exercise](exercises/chromium/bringing-it-together.md)
- [Exercise Solutions](exercises/chromium/solutions.md)

---

# Bare Metal: Morning

- [Welcome](bare-metal.md)
- [`no_std`](bare-metal/no_std.md)
  - [A Minimal Example](bare-metal/minimal.md)
  - [`alloc`](bare-metal/alloc.md)
- [Microcontrollers](bare-metal/microcontrollers.md)
  - [Raw MMIO](bare-metal/microcontrollers/mmio.md)
  - [PACs](bare-metal/microcontrollers/pacs.md)
  - [HAL Crates](bare-metal/microcontrollers/hals.md)
  - [Board Support Crates](bare-metal/microcontrollers/board-support.md)
  - [The Type State Pattern](bare-metal/microcontrollers/type-state.md)
  - [`embedded-hal`](bare-metal/microcontrollers/embedded-hal.md)
  - [`probe-rs` and `cargo-embed`](bare-metal/microcontrollers/probe-rs.md)
    - [Debugging](bare-metal/microcontrollers/debugging.md)
  - [Other Projects](bare-metal/microcontrollers/other-projects.md)
- [Exercises](exercises/bare-metal/morning.md)
  - [Compass](exercises/bare-metal/compass.md)
  - [Solutions](exercises/bare-metal/solutions-morning.md)

# Bare Metal: Afternoon

- [Application Processors](bare-metal/aps.md)
  - [Getting Ready to Rust](bare-metal/aps/entry-point.md)
  - [Inline Assembly](bare-metal/aps/inline-assembly.md)
  - [MMIO](bare-metal/aps/mmio.md)
  - [Let's Write a UART Driver](bare-metal/aps/uart.md)
    - [More Traits](bare-metal/aps/uart/traits.md)
    - [Using It](bare-metal/aps/uart/using.md)
  - [A Better UART Driver](bare-metal/aps/better-uart.md)
    - [Bitflags](bare-metal/aps/better-uart/bitflags.md)
    - [Multiple Registers](bare-metal/aps/better-uart/registers.md)
    - [Driver](bare-metal/aps/better-uart/driver.md)
  - [safe-mmio](bare-metal/aps/safemmio/registers.md)
    - [Driver](bare-metal/aps/safemmio/driver.md)
    - [Using It](bare-metal/aps/safemmio/using.md)
  - [Logging](bare-metal/aps/logging.md)
    - [Using It](bare-metal/aps/logging/using.md)
  - [Exceptions](bare-metal/aps/exceptions.md)
  - [aarch64-rt](bare-metal/aps/aarch64-rt.md)
    - [Exceptions](bare-metal/aps/aarch64-rt/exceptions.md)
  - [Other Projects](bare-metal/aps/other-projects.md)
- [Useful Crates](bare-metal/useful-crates.md)
  - [`zerocopy`](bare-metal/useful-crates/zerocopy.md)
  - [`aarch64-paging`](bare-metal/useful-crates/aarch64-paging.md)
  - [`buddy_system_allocator`](bare-metal/useful-crates/buddy_system_allocator.md)
  - [`tinyvec`](bare-metal/useful-crates/tinyvec.md)
  - [`spin`](bare-metal/useful-crates/spin.md)
- [Bare-Metal on Android](bare-metal/android.md)
  - [`vmbase`](bare-metal/android/vmbase.md)
- [Exercises](exercises/bare-metal/afternoon.md)
  - [RTC Driver](exercises/bare-metal/rtc.md)
  - [Solutions](exercises/bare-metal/solutions-afternoon.md)

---

# Concurrency: Morning

- [Welcome](concurrency/welcome.md)
- [Threads](concurrency/threads.md)
  - [Plain Threads](concurrency/threads/plain.md)
  - [Scoped Threads](concurrency/threads/scoped.md)
- [Channels](concurrency/channels.md)
  - [Senders and Receivers](concurrency/channels/senders-receivers.md)
  - [Unbounded Channels](concurrency/channels/unbounded.md)
  - [Bounded Channels](concurrency/channels/bounded.md)
- [`Send` and `Sync`](concurrency/send-sync.md)
  - [Marker Traits](concurrency/send-sync/marker-traits.md)
  - [`Send`](concurrency/send-sync/send.md)
  - [`Sync`](concurrency/send-sync/sync.md)
  - [Examples](concurrency/send-sync/examples.md)
- [Shared State](concurrency/shared-state.md)
  - [`Arc`](concurrency/shared-state/arc.md)
  - [`Mutex`](concurrency/shared-state/mutex.md)
  - [Example](concurrency/shared-state/example.md)
- [Exercises](concurrency/sync-exercises.md)
  - [Dining Philosophers](concurrency/sync-exercises/dining-philosophers.md)
  - [Multi-threaded Link Checker](concurrency/sync-exercises/link-checker.md)
  - [Solutions](concurrency/sync-exercises/solutions.md)

# Concurrency: Afternoon

- [Welcome](concurrency/welcome-async.md)
- [Async Basics](concurrency/async.md)
  - [`async`/`await`](concurrency/async/async-await.md)
  - [Futures](concurrency/async/futures.md)
  - [State Machine](concurrency/async/state-machine.md)
  - [Runtimes](concurrency/async/runtimes.md)
    - [Tokio](concurrency/async/runtimes/tokio.md)
  - [Tasks](concurrency/async/tasks.md)
- [Channels and Control Flow](concurrency/async-control-flow.md)
  - [Async Channels](concurrency/async-control-flow/channels.md)
  - [Join](concurrency/async-control-flow/join.md)
  - [Select](concurrency/async-control-flow/select.md)
- [Pitfalls](concurrency/async-pitfalls.md)
  - [Blocking the Executor](concurrency/async-pitfalls/blocking-executor.md)
  - [`Pin`](concurrency/async-pitfalls/pin.md)
  - [Async Traits](concurrency/async-pitfalls/async-traits.md)
  - [Cancellation](concurrency/async-pitfalls/cancellation.md)
- [Exercises](concurrency/async-exercises.md)
  - [Dining Philosophers](concurrency/async-exercises/dining-philosophers.md)
  - [Broadcast Chat Application](concurrency/async-exercises/chat-app.md)
  - [Solutions](concurrency/async-exercises/solutions.md)

---

# Idiomatic Rust

- [Welcome](idiomatic/welcome.md)
- [Foundations of API Design](idiomatic/foundations-api-design.md)
  - [Meaningful Doc Comments](idiomatic/foundations-api-design/meaningful-doc-comments.md)
    - [Who Are You Writing For?](idiomatic/foundations-api-design/meaningful-doc-comments/who-are-you-writing-for.md)
    - [Library vs Application docs](idiomatic/foundations-api-design/meaningful-doc-comments/library-vs-application-docs.md)
    - [Anatomy of a Doc Comment](idiomatic/foundations-api-design/meaningful-doc-comments/anatomy-of-a-doc-comment.md)
    - [Name Drop and Signpost](idiomatic/foundations-api-design/meaningful-doc-comments/name-drop-signpost.md)
    - [Avoid Redundancy](idiomatic/foundations-api-design/meaningful-doc-comments/avoid-redundancy.md)
    - [Name and Signature are Not Enough](idiomatic/foundations-api-design/meaningful-doc-comments/what-isnt-docs.md)
    - [What and Why, not How and Where](idiomatic/foundations-api-design/meaningful-doc-comments/what-why-not-how-where.md)
    - [Exercise](idiomatic/foundations-api-design/meaningful-doc-comments/exercise.md)
  - [Predictable API](idiomatic/foundations-api-design/predictable-api.md)
    - [Naming conventions](idiomatic/foundations-api-design/predictable-api/naming-conventions.md)
      - [New](idiomatic/foundations-api-design/predictable-api/naming-conventions/new.md)
      - [Get](idiomatic/foundations-api-design/predictable-api/naming-conventions/get.md)
      - [Push](idiomatic/foundations-api-design/predictable-api/naming-conventions/push.md)
      - [Is](idiomatic/foundations-api-design/predictable-api/naming-conventions/is.md)
      - [Mut](idiomatic/foundations-api-design/predictable-api/naming-conventions/mut.md)
      - [With: Constructor](idiomatic/foundations-api-design/predictable-api/naming-conventions/with-constructor.md)
      - [With: Copy-and-change](idiomatic/foundations-api-design/predictable-api/naming-conventions/with-copy-setter.md)
      - [With: Closures](idiomatic/foundations-api-design/predictable-api/naming-conventions/with-closure.md)
      - [With in normal use](idiomatic/foundations-api-design/predictable-api/naming-conventions/with-word.md)
      - [Try](idiomatic/foundations-api-design/predictable-api/naming-conventions/try.md)
      - [From](idiomatic/foundations-api-design/predictable-api/naming-conventions/from.md)
      - [Into](idiomatic/foundations-api-design/predictable-api/naming-conventions/into.md)
      - [Into inner](idiomatic/foundations-api-design/predictable-api/naming-conventions/into_inner.md)
      - [By](idiomatic/foundations-api-design/predictable-api/naming-conventions/by.md)
      - [Unchecked](idiomatic/foundations-api-design/predictable-api/naming-conventions/unchecked.md)
      - [To](idiomatic/foundations-api-design/predictable-api/naming-conventions/to.md)
      - [As and Ref](idiomatic/foundations-api-design/predictable-api/naming-conventions/as-and-ref.md)
      - [Raw parts](idiomatic/foundations-api-design/predictable-api/naming-conventions/raw_parts.md)
      - [Exercise](idiomatic/foundations-api-design/predictable-api/naming-conventions/exercise.md)
    - [Implementing Common Traits](idiomatic/foundations-api-design/predictable-api/common-traits.md)
      - [Debug](idiomatic/foundations-api-design/predictable-api/common-traits/debug.md)
      - [PartialEq and Eq](idiomatic/foundations-api-design/predictable-api/common-traits/partialeq-eq.md)
      - [PartialOrd and Ord](idiomatic/foundations-api-design/predictable-api/common-traits/partialord-ord.md)
      - [Hash](idiomatic/foundations-api-design/predictable-api/common-traits/hash.md)
      - [Clone](idiomatic/foundations-api-design/predictable-api/common-traits/clone.md)
      - [Copy](idiomatic/foundations-api-design/predictable-api/common-traits/copy.md)
      - [Serialize and Deserialize](idiomatic/foundations-api-design/predictable-api/common-traits/serde.md)
      - [From and Into](idiomatic/foundations-api-design/predictable-api/common-traits/from-into.md)
      - [TryFrom and TryInto](idiomatic/foundations-api-design/predictable-api/common-traits/try-from-into.md)
      - [Display](idiomatic/foundations-api-design/predictable-api/common-traits/display.md)
- [Leveraging the Type System](idiomatic/leveraging-the-type-system.md)
  - [Newtype Pattern](idiomatic/leveraging-the-type-system/newtype-pattern.md)
    - [Semantic Confusion](idiomatic/leveraging-the-type-system/newtype-pattern/semantic-confusion.md)
    - [Parse, Don't Validate](idiomatic/leveraging-the-type-system/newtype-pattern/parse-don-t-validate.md)
    - [Is It Encapsulated?](idiomatic/leveraging-the-type-system/newtype-pattern/is-it-encapsulated.md)
  - [RAII](idiomatic/leveraging-the-type-system/raii.md)
    - [Drop Skipped](idiomatic/leveraging-the-type-system/raii/drop_skipped.md)
    - [Mutex](idiomatic/leveraging-the-type-system/raii/mutex.md)
    - [Drop Guards](idiomatic/leveraging-the-type-system/raii/drop_guards.md)
    - [Drop Bomb](idiomatic/leveraging-the-type-system/raii/drop_bomb.md)
    - [Drop Bomb Forget](idiomatic/leveraging-the-type-system/raii/drop_bomb_forget.md)
    - [forget and drop functions](idiomatic/leveraging-the-type-system/raii/forget_and_drop.md)
    - [Scope Guard](idiomatic/leveraging-the-type-system/raii/scope_guard.md)
    - [Drop Option](idiomatic/leveraging-the-type-system/raii/drop_option.md)
  - [Extension Traits](idiomatic/leveraging-the-type-system/extension-traits.md)
    - [Extending Foreign Types](idiomatic/leveraging-the-type-system/extension-traits/extending-foreign-types.md)
    - [Method Resolution Conflicts](idiomatic/leveraging-the-type-system/extension-traits/method-resolution-conflicts.md)
    - [Trait Method Conflicts](idiomatic/leveraging-the-type-system/extension-traits/trait-method-conflicts.md)
    - [Extending Other Traits](idiomatic/leveraging-the-type-system/extension-traits/extending-other-traits.md)
    - [Should I Define An Extension Trait?](idiomatic/leveraging-the-type-system/extension-traits/should-i-define-an-extension-trait.md)
  - [Typestate Pattern](idiomatic/leveraging-the-type-system/typestate-pattern.md)
    - [Typestate Pattern Example](idiomatic/leveraging-the-type-system/typestate-pattern/typestate-example.md)
    - [Beyond Simple Typestate](idiomatic/leveraging-the-type-system/typestate-pattern/typestate-advanced.md)
    - [Typestate Pattern with Generics](idiomatic/leveraging-the-type-system/typestate-pattern/typestate-generics.md)
      - [Serializer: implement Root](idiomatic/leveraging-the-type-system/typestate-pattern/typestate-generics/root.md)
      - [Serializer: implement Struct](idiomatic/leveraging-the-type-system/typestate-pattern/typestate-generics/struct.md)
      - [Serializer: implement Property](idiomatic/leveraging-the-type-system/typestate-pattern/typestate-generics/property.md)
      - [Serializer: Complete implementation](idiomatic/leveraging-the-type-system/typestate-pattern/typestate-generics/complete.md)
  - [Borrow checking invariants](idiomatic/leveraging-the-type-system/borrow-checker-invariants.md)
    - [Lifetimes and Borrows: the Abstract Rules](idiomatic/leveraging-the-type-system/borrow-checker-invariants/generalizing-ownership.md)
    - [Single-use values](idiomatic/leveraging-the-type-system/borrow-checker-invariants/single-use-values.md)
    - [Mutually Exclusive References / "Aliasing XOR Mutability"](idiomatic/leveraging-the-type-system/borrow-checker-invariants/aliasing-xor-mutability.md)
    - [PhantomData and Types](idiomatic/leveraging-the-type-system/borrow-checker-invariants/phantomdata-01-types.md)
    - [PhantomData and Types (implementation)](idiomatic/leveraging-the-type-system/borrow-checker-invariants/phantomdata-02-types-implemented.md)
    - [PhantomData: Lifetimes for External Resources](idiomatic/leveraging-the-type-system/borrow-checker-invariants/phantomdata-03-lifetimes.md)
    - [PhantomData: OwnedFd & BorrowedFd](idiomatic/leveraging-the-type-system/borrow-checker-invariants/phantomdata-04-borrowedfd.md)
  - [Token Types](idiomatic/leveraging-the-type-system/token-types.md)
    - [Permission Tokens](idiomatic/leveraging-the-type-system/token-types/permission-tokens.md)
    - [Token Types with Data: Mutex Guards](idiomatic/leveraging-the-type-system/token-types/mutex-guard.md)
    - [Branded pt 1: Variable-specific tokens](idiomatic/leveraging-the-type-system/token-types/branded-01-motivation.md)
    - [Branded pt 2: `PhantomData` and Lifetime Subtyping](idiomatic/leveraging-the-type-system/token-types/branded-02-phantomdata.md)
    - [Branded pt 3: Implementation](idiomatic/leveraging-the-type-system/token-types/branded-03-impl.md)
    - [Branded pt 4: Branded types in action.](idiomatic/leveraging-the-type-system/token-types/branded-04-in-action.md)
- [Polymorphism](idiomatic/polymorphism.md)
  - [Refresher](idiomatic/polymorphism/refresher.md)
    - [Traits](idiomatic/polymorphism/refresher/traits.md)
    - [Trait Bounds](idiomatic/polymorphism/refresher/trait-bounds.md)
    - [Deriving Traits](idiomatic/polymorphism/refresher/deriving-traits.md)
    - [Default Implementations](idiomatic/polymorphism/refresher/default-impls.md)
    - [Supertraits](idiomatic/polymorphism/refresher/supertraits.md)
    - [Blanket Implementations](idiomatic/polymorphism/refresher/blanket-impls.md)
    - [Conditional Methods](idiomatic/polymorphism/refresher/conditional-methods.md)
    - [Orphan Rule](idiomatic/polymorphism/refresher/orphan-rule.md)
    - [Statically Sized and Dynamically Sized types](idiomatic/polymorphism/refresher/sized.md)
    - [Monomorphization and Binary Size](idiomatic/polymorphism/refresher/monomorphization.md)
  - [From OOP to Rust](idiomatic/polymorphism/from-oop-to-rust.md)
    - [Inheritance](idiomatic/polymorphism/from-oop-to-rust/inheritance.md)
    - [Why no Inheritance in Rust?](idiomatic/polymorphism/from-oop-to-rust/why-no-inheritance.md)
    - [Inheritance from Rust's Perspective](idiomatic/polymorphism/from-oop-to-rust/switch-perspective.md)
    - ["Inheritance" in Rust and Supertraits](idiomatic/polymorphism/from-oop-to-rust/supertraits.md)
    - [Composition over Inheritance](idiomatic/polymorphism/from-oop-to-rust/composition.md)
    - [Trait Objects and Dynamic Dispatch](idiomatic/polymorphism/from-oop-to-rust/dynamic-dispatch/dyn-trait.md)
    - [Dyn Compatibility](idiomatic/polymorphism/from-oop-to-rust/dynamic-dispatch/dyn-compatible.md)
    - [Generics vs Trait Objects](idiomatic/polymorphism/from-oop-to-rust/dynamic-dispatch/dyn-vs-generics.md)
    - [Limits of Trait Objects](idiomatic/polymorphism/from-oop-to-rust/dynamic-dispatch/limits.md)
    - [Heterogeneous Collections](idiomatic/polymorphism/from-oop-to-rust/dynamic-dispatch/heterogeneous.md)
    - [The `Any` Trait](idiomatic/polymorphism/from-oop-to-rust/dynamic-dispatch/any-trait.md)
    - [Pitfall: Reaching too quickly for `dyn Trait`](idiomatic/polymorphism/from-oop-to-rust/dynamic-dispatch/pitfalls.md)
    - [Sealed Traits](idiomatic/polymorphism/from-oop-to-rust/sealed-traits.md)
    - [Sealing with Enums](idiomatic/polymorphism/from-oop-to-rust/sealing-with-enums.md)
    - [Traits for Polymorphism users can extend](idiomatic/polymorphism/from-oop-to-rust/sticking-with-traits.md)
    - [Problem solving: Break Down the Problem](idiomatic/polymorphism/from-oop-to-rust/problem-solving.md)

---

# Unsafe

- [Welcome](unsafe-deep-dive/welcome.md)
- [Setup](unsafe-deep-dive/setup.md)
- [Introduction](unsafe-deep-dive/introduction.md)
  - [Defining Unsafe Rust](unsafe-deep-dive/introduction/definition.md)
  - [Purpose of the unsafe keyword](unsafe-deep-dive/introduction/purpose.md)
  - [Two roles of the unsafe keyword](unsafe-deep-dive/introduction/two-roles.md)
  - [Warm Up Examples](unsafe-deep-dive/introduction/warm-up.md)
    - [Using an unsafe block](unsafe-deep-dive/introduction/warm-up/unsafe-block.md)
    - [Defining an unsafe function](unsafe-deep-dive/introduction/warm-up/unsafe-fn.md)
    - [Implementing an unsafe trait](unsafe-deep-dive/introduction/warm-up/unsafe-impl.md)
    - [Defining an unsafe trait](unsafe-deep-dive/introduction/warm-up/unsafe-trait.md)
  - [Characteristics of Unsafe Rust](unsafe-deep-dive/introduction/characteristics-of-unsafe-rust.md)
    - [Dangerous](unsafe-deep-dive/introduction/characteristics-of-unsafe-rust/dangerous.md)
    - [Sometimes necessary](unsafe-deep-dive/introduction/characteristics-of-unsafe-rust/sometimes-necessary.md)
    - [Sometimes useful](unsafe-deep-dive/introduction/characteristics-of-unsafe-rust/sometimes-useful.md)
  - [Responsibility shift](unsafe-deep-dive/introduction/responsibility-shift.md)
  - [Stronger development workflow required](unsafe-deep-dive/introduction/impact-on-workflow.md)
  - [Example: may_overflow](unsafe-deep-dive/introduction/may_overflow.md)
- [Safety Preconditions](unsafe-deep-dive/safety-preconditions.md)
  - [Common Preconditions](unsafe-deep-dive/safety-preconditions/common-preconditions.md)
    - [Getter example](unsafe-deep-dive/safety-preconditions/getter.md)
  - [Semantic preconditions](unsafe-deep-dive/safety-preconditions/semantic-preconditions.md)
    - [Example: u8 to bool](unsafe-deep-dive/safety-preconditions/u8-to-bool.md)
  - [Determining preconditions](unsafe-deep-dive/safety-preconditions/determining.md)
    - [Example: references](unsafe-deep-dive/safety-preconditions/references.md)
  - [Defining your own preconditions](unsafe-deep-dive/safety-preconditions/defining.md)
    - [Example: ASCII Type](unsafe-deep-dive/safety-preconditions/ascii.md)
- [Rules of the game](unsafe-deep-dive/rules-of-the-game.md)
  - [Rust is sound](unsafe-deep-dive/rules-of-the-game/rust-is-sound.md)
  - [Copying memory](unsafe-deep-dive/rules-of-the-game/copying-memory.md)
    - [Safe Rust](unsafe-deep-dive/rules-of-the-game/copying-memory/safe.md)
    - [Encapsulated Unsafe Rust](unsafe-deep-dive/rules-of-the-game/copying-memory/encapsulated-unsafe.md)
    - [Exposed Unsafe Rust](unsafe-deep-dive/rules-of-the-game/copying-memory/exposed-unsafe.md)
    - [Documented safety preconditions](unsafe-deep-dive/rules-of-the-game/copying-memory/documented-safety-preconditions.md)
    - [Crying Wolf](unsafe-deep-dive/rules-of-the-game/copying-memory/crying-wolf.md)
  - [3 shapes of sound Rust](unsafe-deep-dive/rules-of-the-game/3-shapes-of-sound-rust.md)
  - [Soundness Proof](unsafe-deep-dive/rules-of-the-game/soundness-proof.md)
    - [Soundness](unsafe-deep-dive/rules-of-the-game/soundness-proof/soundness.md)
    - [Corollary](unsafe-deep-dive/rules-of-the-game/soundness-proof/corollary.md)
    - [Unsoundness](unsafe-deep-dive/rules-of-the-game/soundness-proof/unsoundness.md)
- [Memory Lifecycle](unsafe-deep-dive/memory-lifecycle.md)
- [Initialization](unsafe-deep-dive/initialization.md)
  - [MaybeUninit<T>](unsafe-deep-dive/initialization/maybeuninit.md)
    - [Arrays of uninit](unsafe-deep-dive/initialization/maybeuninit/arrays.md)
    - [MaybeUninit::zeroed()](unsafe-deep-dive/initialization/maybeuninit/zeroed-method.md)
    - [ptr::write vs assignment](unsafe-deep-dive/initialization/maybeuninit/write-vs-assignment.md)
  - [How to initialize memory](unsafe-deep-dive/initialization/how-to-initialize-memory.md)
  - [Partial initialization](unsafe-deep-dive/initialization/partial-initialization.md)
- [Pinning](unsafe-deep-dive/pinning.md)
  - [What pinning is](unsafe-deep-dive/pinning/what-pinning-is.md)
  - [What a move is](unsafe-deep-dive/pinning/what-a-move-is.md)
  - [Definition of Pin<Ptr>](unsafe-deep-dive/pinning/definition-of-pin.md)
  - [Why it's difficult](unsafe-deep-dive/pinning/why-difficult.md)
  - [`Unpin` trait](unsafe-deep-dive/pinning/unpin-trait.md)
  - [`PhantomPinned`](unsafe-deep-dive/pinning/phantompinned.md)
  - [Self-Referential Buffer Example](unsafe-deep-dive/pinning/self-referential-buffer.md)
    - [C++ implementation](unsafe-deep-dive/pinning/self-referential-buffer/cpp.md)
    - [Modeled in Rust](unsafe-deep-dive/pinning/self-referential-buffer/rust.md)
      - [With a raw pointer](unsafe-deep-dive/pinning/self-referential-buffer/rust-raw-pointers.md)
      - [With an integer offset](unsafe-deep-dive/pinning/self-referential-buffer/rust-offset.md)
      - [With `Pin<Ptr>`](unsafe-deep-dive/pinning/self-referential-buffer/rust-pin.md)
  - [`Pin<Ptr>` and `Drop`](unsafe-deep-dive/pinning/pin-and-drop.md)
    - [Worked Example](unsafe-deep-dive/pinning/drop-and-not-unpin-worked-example.md)
- [FFI](unsafe-deep-dive/ffi.md)
  - [Language Interop](unsafe-deep-dive/ffi/language-interop.md)
  - [Strategies](unsafe-deep-dive/ffi/strategies.md)
  - [Consideration: Type Safety](unsafe-deep-dive/ffi/type-safety.md)
  - [Language differences](unsafe-deep-dive/ffi/language-differences.md)
    - [Different representations](unsafe-deep-dive/ffi/language-differences/representations.md)
    - [Different semantics](unsafe-deep-dive/ffi/language-differences/semantics.md)
    - [Rust ↔ C](unsafe-deep-dive/ffi/language-differences/rust-and-c.md)
    - [C++ ↔ C](unsafe-deep-dive/ffi/language-differences/cpp-and-c.md)
    - [Rust ↔ C++](unsafe-deep-dive/ffi/language-differences/rust-and-cpp.md)
  - [`abs(3)`](unsafe-deep-dive/ffi/abs.md)
  - [`rand(3)`](unsafe-deep-dive/ffi/rand.md)
  - [Exercise:C library](unsafe-deep-dive/ffi/c-library-example.md)
  - [Exercise: C++ library](unsafe-deep-dive/ffi/cpp-library-example.md)

---

# Final Words

- [Thanks!](thanks.md)
- [Glossary](glossary.md)
- [Other Resources](other-resources.md)
- [Credits](credits.md)
