---
source: https://iinventedlight.com/library/notes/rust-option.md
title: "Option: a value that may be Some or None"
license: CC-BY-4.0
license_url: https://creativecommons.org/licenses/by/4.0/
source_license: "MIT OR Apache-2.0 (Rust Standard Library); MIT OR Apache-2.0 (Rust By Example); prose restates cited source lines in own words"
license_family: mixed-green
attribution: "Summary by iinventedlight (AI-assisted). Sources: Rust Standard Library, std::option; Rust By Example, Option. MIT OR Apache-2.0 (https://raw.githubusercontent.com/rust-lang/rust/master/COPYRIGHT). Copyright the Rust Project Developers. MIT OR Apache-2.0 (https://raw.githubusercontent.com/rust-lang/rust-by-example/master/LICENSE-MIT). Copyright the Rust Project Developers."
author: "iinventedlight (synthesis of cited sources); text drafted with AI assistance"
date: 2026-11-23
status: published
approved_by: "Cole Withington, 2026-11-27 14:30 PT: \"Yes, publish all of that now\""
checked_on: 2026-11-23
as_of: 2026-11-23
confidence: medium
untested: "Not reproduced (2026-11-23). Official docs and source files were read; no test suite, server, or API call was run for this note."
category: coding-references
topic_area: "code-systems: rust-option"
tags: [rust, option, enum, error-handling]
client: Librarian
sources:
  - id: S1
    title: "std::option"
    publisher: Rust Standard Library
    url: https://doc.rust-lang.org/std/option/index.html
    accessed: 2026-11-23
    license: "MIT OR Apache-2.0"
  - id: S2
    title: "Option"
    publisher: Rust By Example
    url: https://doc.rust-lang.org/rust-by-example/std/option.html
    accessed: 2026-11-23
    license: "MIT OR Apache-2.0"
---
# Option: a value that may be Some or None
**Answer:** Option is an enum with two variants. Some wraps a value. None indicates failure or lack of value. Use Option to catch the failure of some parts of a program instead of calling panic!. Unwrapping a Some variant will extract the value wrapped. Unwrapping a None variant will panic.

## The two variants

When part of a program may fail, Option lets you catch that failure instead of calling panic!.

The enum has two variants.

None indicates failure or lack of value.

Some(value) is a tuple struct that holds a value of type T.

Like other enums, you can match on an Option.

unwrap on Some takes out the wrapped value. unwrap on None panics.

A None binding needs a type annotation.

## How the standard library describes it

Type Option stands for an optional value.

Option values can be pattern matched, just like other enums.

The Some variant contains a value. The None variant does not.

Typical uses include initial values, returns from partial functions, and optional struct fields.

Code often pairs Option with pattern matching so the None case is always handled.

## See also

- [rust-enums](https://iinventedlight.com/library/notes/rust-enums/)
- [rust-match](https://iinventedlight.com/library/notes/rust-match/)
- [rust-if-let](https://iinventedlight.com/library/notes/rust-if-let/)
- [rust-error-handling-result](https://iinventedlight.com/library/notes/rust-error-handling-result/)

## Claims

- id: C1
  claim: Option can catch a failure instead of calling panic!.
  source: S2
  evidence: "instead of calling"

- id: C2
  claim: None indicates failure or lack of value.
  source: S2
  evidence: "indicate failure or lack of value"

- id: C3
  claim: Some wraps a value of type T.
  source: S2
  evidence: "wraps a"

- id: C4
  claim: Unwrapping None panics.
  source: S2
  evidence: "Unwrapping a `None` variant will"

- id: C5
  claim: Every Option is either Some with a value, or None.
  source: S1
  evidence: "either Some and contains a value, or None"

## Sources

- [S1] std::option. Rust Standard Library. https://doc.rust-lang.org/std/option/index.html . License: MIT OR Apache-2.0. Accessed 2026-11-23.

- [S2] Option. Rust By Example. https://doc.rust-lang.org/rust-by-example/std/option.html . License: MIT OR Apache-2.0. Accessed 2026-11-23.

License: this note is CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Summary by iinventedlight (AI-assisted). Sources: Rust Standard Library, std::option; Rust By Example, Option. MIT OR Apache-2.0 (https://raw.githubusercontent.com/rust-lang/rust/master/COPYRIGHT). Copyright the Rust Project Developers. MIT OR Apache-2.0 (https://raw.githubusercontent.com/rust-lang/rust-by-example/master/LICENSE-MIT). Copyright the Rust Project Developers. Text was condensed and changed from the originals.

---

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