---
title: Rust Result leaves recovery policy to the caller
slug: rust-error-handling-result
license: CC-BY-4.0
license_url: https://creativecommons.org/licenses/by/4.0/
source: https://iinventedlight.com/library/notes/rust-error-handling-result.md
source_license: MIT
attribution: Original synthesis by iinventedlight, drafted by Librarian with AI assistance; based on the attributed sources
  below.
author: Librarian
client: Librarian
date: '2026-11-05'
checked_on: '2026-11-05'
as_of: '2026-11-05'
status: published
confidence: medium
category: coding-references
tags:
- rust
- error
- handling
untested: Reference note. No code or commands were run to validate behavior.
sources:
- id: S1
  title: Recoverable errors with Result
  publisher: The Rust Project Developers
  url: https://doc.rust-lang.org/book/ch09-02-recoverable-errors-with-result.html
  accessed: '2026-11-05'
  license: MIT
  license_url: https://raw.githubusercontent.com/rust-lang/book/main/LICENSE-MIT
  license_verified: '2026-11-05'
  green: true
  attribution: The Rust Project Developers; Recoverable errors with Result; MIT
  snapshot: _fetched/rust-result.txt
- id: S2
  title: To panic or not to panic
  publisher: The Rust Project Developers
  url: https://doc.rust-lang.org/book/ch09-03-to-panic-or-not-to-panic.html
  accessed: '2026-11-05'
  license: MIT
  license_url: https://raw.githubusercontent.com/rust-lang/book/main/LICENSE-MIT
  license_verified: '2026-11-05'
  green: true
  attribution: The Rust Project Developers; To panic or not to panic; MIT
  snapshot: _fetched/rust-panic.txt
---
# Rust Result leaves recovery policy to the caller

## Summary
`Result<T, E>` represents either a successful value or an error. Its `Ok` and `Err` variants let a function report failure without deciding that the program must stop. [S1, S2]

## Details
The Rust Book uses `File::open` to show why the success value and error value need different types. Returning `Result` lets the caller recover, forward the error, or decide that failure is unrecoverable. The Book recommends that choice as the default for a function that may fail, while allowing panics in cases such as examples and prototypes. [S1, S2]

## Claims
- id: C1
  claim: "Result has Ok and Err variants."
  source: S1
  evidence: "two\nvariants, Ok and Err"
- id: C2
  claim: "The success value is carried in Ok."
  source: S1
  evidence: "a success case within the Ok variant"
- id: C3
  claim: "Returning Result gives calling code a choice about recovery."
  source: S2
  evidence: "you give the\ncalling code options"

## Sources
- [S1] Recoverable errors with Result. The Rust Project Developers. https://doc.rust-lang.org/book/ch09-02-recoverable-errors-with-result.html. MIT; license: https://raw.githubusercontent.com/rust-lang/book/main/LICENSE-MIT. Accessed 2026-11-05.
- [S2] To panic or not to panic. The Rust Project Developers. https://doc.rust-lang.org/book/ch09-03-to-panic-or-not-to-panic.html. MIT; license: https://raw.githubusercontent.com/rust-lang/book/main/LICENSE-MIT. Accessed 2026-11-05.

## Attribution and notices
This note is CC BY 4.0. Source material has been condensed and restated; short evidence excerpts retain their source license.

Copyright (c) 2010 The Rust Project Developers

Permission is hereby granted, free of charge, to any
person obtaining a copy of this software and associated
documentation files (the "Software"), to deal in the
Software without restriction, including without
limitation the rights to use, copy, modify, merge,
publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software
is furnished to do so, subject to the following
conditions:

The above copyright notice and this permission notice
shall be included in all copies or substantial portions
of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF
ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT
SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
