---
source: https://iinventedlight.com/library/notes/rust-if-let.md
title: "if let: concise control flow for one pattern"
license: CC-BY-4.0
license_url: https://creativecommons.org/licenses/by/4.0/
source_license: "MIT OR Apache-2.0 (The Rust Programming Language); 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: The Rust Programming Language, Concise Control Flow with if let and let...else; Rust by Example, if let. MIT OR Apache-2.0 (https://raw.githubusercontent.com/rust-lang/book/main/LICENSE-MIT). 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-if-let"
tags: [rust, if-let, pattern-matching, enums]
client: Librarian
sources:
  - id: S1
    title: "Concise Control Flow with if let and let...else"
    publisher: The Rust Programming Language
    url: https://doc.rust-lang.org/book/ch06-03-if-let.html
    accessed: 2026-11-23
    license: "MIT OR Apache-2.0"
  - id: S2
    title: "if let"
    publisher: Rust by Example
    url: https://doc.rust-lang.org/rust-by-example/flow_control/if_let.html
    accessed: 2026-11-23
    license: "MIT OR Apache-2.0"
---
# if let: concise control flow for one pattern
**Answer:** The if let syntax lets you combine if and let in a less verbose way. You handle values that match one pattern while ignoring the rest.

## The book form

The book introduces if let as a less verbose way to handle values that match one pattern.

The same page also covers let...else as concise control flow.

The following code behaves the same as the match in the listing: if let Some(max) = config_max.

## Rust by Example

Matching enums with match can feel awkward in some use cases.

For those cases if let is cleaner, and it also lets you specify various failure options.

Read the construct as: if let destructures the value into the pattern, then evaluate the block.

## See also

- [rust-enums](https://iinventedlight.com/library/notes/rust-enums/)
- [rust-impl-trait](https://iinventedlight.com/library/notes/rust-impl-trait/)

## Claims

- id: C1
  claim: if let combines if and let to handle one pattern and ignore the rest.
  source: S1
  evidence: "combine if and let into a less verbose way"

- id: C2
  claim: The book also presents let...else as related concise control flow.
  source: S1
  evidence: "if let and let...else"

- id: C3
  claim: if let is cleaner than a full match for some enum cases.
  source: S2
  evidence: "if let is cleaner for this use case"

- id: C4
  claim: if let can specify various failure options.
  source: S2
  evidence: "allows various failure options to be specified"

## Sources

- [S1] Concise Control Flow with if let and let...else. The Rust Programming Language. https://doc.rust-lang.org/book/ch06-03-if-let.html . License: MIT OR Apache-2.0. Accessed 2026-11-23.

- [S2] if let. Rust by Example. https://doc.rust-lang.org/rust-by-example/flow_control/if_let.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: The Rust Programming Language, Concise Control Flow with if let and let...else; Rust by Example, if let. MIT OR Apache-2.0 (https://raw.githubusercontent.com/rust-lang/book/main/LICENSE-MIT). 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).
