---
source: https://iinventedlight.com/library/notes/rust-box-and-deref.md
title: "Box and Deref in Rust"
license: CC-BY-4.0
license_url: https://creativecommons.org/licenses/by/4.0/
source_license: "MIT OR Apache-2.0 (rust-lang/book and cited companions); prose restates cited source lines in own words"
license_family: rust-mit
attribution: "Summary by iinventedlight (AI-assisted). Sources: Rust book + Rust by Example Box page (MIT OR Apache-2.0). Notices: The Rust Programming Language book (rust-lang/book): Copyright (c) 2010 The Rust Project Developers; MIT OR Apache-2.0, used under MIT (https://github.com/rust-lang/book/blob/main/LICENSE-MIT). Rust by Example (rust-lang/rust-by-example): Copyright (c) 2014 Jorge Aparicio; MIT OR Apache-2.0, used under MIT (https://github.com/rust-lang/rust-by-example/blob/master/LICENSE-MIT)."
author: "iinventedlight (synthesis of cited sources); text drafted with AI assistance"
date: 2026-11-09
status: published
approved_by: "Cole Withington, 2026-11-09 13:40 PT: \"Yes, publish all 15 Rust drafts\""
checked_on: 2026-11-09
as_of: 2026-11-09
confidence: medium
untested: "No Rust code was run for this note; only the fetched documentation pages were read."
category: coding-references
topic_area: "code-systems: Rust smart pointers"
tags: [rust, box, deref, smart-pointers]
client: Librarian
sources:
  - id: S1
    title: "Using Box<T> to Point to Data on the Heap"
    publisher: The Rust Project (The Rust Programming Language book)
    url: https://doc.rust-lang.org/book/ch15-01-box.html
    accessed: 2026-11-09
    license: "MIT OR Apache-2.0"
  - id: S2
    title: "Treating Smart Pointers Like Regular References with Deref"
    publisher: The Rust Project (The Rust Programming Language book)
    url: https://doc.rust-lang.org/book/ch15-02-deref.html
    accessed: 2026-11-09
    license: "MIT OR Apache-2.0"
  - id: S3
    title: "Box, stack and heap - Rust By Example"
    publisher: Rust by Example (rust-lang/rust-by-example)
    url: https://doc.rust-lang.org/rust-by-example/std/box.html
    accessed: 2026-11-09
    license: "MIT OR Apache-2.0"
---
# Box and Deref in Rust

**Answer:** `Box<T>` stores a value on the heap. Boxes are the straightforward smart pointer written as `Box<T>`.

## Deref

Implement `Deref` to customize what `*` does for your type. Deref coercion then turns a reference to a `Deref` type into a reference to its target type.

A `Box<T>` is a smart pointer to a heap-allocated value of type `T`.

## Claims

- id: C1
  claim: Boxes allow you to store data on the heap rather than the stack.
  source: S1
  evidence: "Boxes allow you to store data on the heap rather than the stack."
- id: C2
  claim: Box is a straightforward smart pointer type written Box<T>.
  source: S1
  evidence: "straightforward smart pointer is a box, whose type is written Box<T>."
- id: C3
  claim: Implementing Deref customizes the behavior of the dereference operator.
  source: S2
  evidence: "Implementing the Deref trait allows you to customize the behavior of the dereference operator *"
- id: C4
  claim: Deref coercion converts a reference to a Deref type into another reference.
  source: S2
  evidence: "Deref coercion converts a reference to a type that implements the Deref trait into a"

- id: C5
  claim: Values can be boxed (allocated on the heap) by creating a Box<T>.
  source: S3
  evidence: "Values can be boxed (allocated on the heap) by creating a Box<T>."

## Sources

- [S1] Using Box<T> to Point to Data on the Heap. The Rust Project (The Rust Programming Language book). https://doc.rust-lang.org/book/ch15-01-box.html . License: MIT OR Apache-2.0. Accessed 2026-11-09.
- [S2] Treating Smart Pointers Like Regular References with Deref. The Rust Project (The Rust Programming Language book). https://doc.rust-lang.org/book/ch15-02-deref.html . License: MIT OR Apache-2.0. Accessed 2026-11-09.

- [S3] Box, stack and heap - Rust By Example. Rust by Example (rust-lang/rust-by-example). https://doc.rust-lang.org/rust-by-example/std/box.html . License: MIT OR Apache-2.0. Accessed 2026-11-09.

License: this note is CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Summary by iinventedlight (AI-assisted). Sources and notices: The Rust Programming Language book (rust-lang/book): Copyright (c) 2010 The Rust Project Developers; MIT OR Apache-2.0, used under MIT (https://github.com/rust-lang/book/blob/main/LICENSE-MIT). Rust by Example (rust-lang/rust-by-example): Copyright (c) 2014 Jorge Aparicio; MIT OR Apache-2.0, used under MIT (https://github.com/rust-lang/rust-by-example/blob/master/LICENSE-MIT). Text was condensed and changed from the originals.

---

Agents: [/agents.md](/agents.md) | [/.well-known/agent-library.json](/.well-known/agent-library.json).
