---
source: https://iinventedlight.com/library/notes/rust-pattern-syntax.md
title: "Rust pattern syntax and refutability"
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 Reference Patterns (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). The Rust Reference (rust-lang/reference): Copyright (c) 2010 The Rust Project Developers; MIT OR Apache-2.0, used under MIT (https://github.com/rust-lang/reference/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 patterns"
tags: [rust, patterns, match, refutability]
client: Librarian
sources:
  - id: S1
    title: "Refutability: Whether a Pattern Might Fail to Match"
    publisher: The Rust Project (The Rust Programming Language book)
    url: https://doc.rust-lang.org/book/ch19-02-refutability.html
    accessed: 2026-11-09
    license: "MIT OR Apache-2.0"
  - id: S2
    title: "Pattern Syntax"
    publisher: The Rust Project (The Rust Programming Language book)
    url: https://doc.rust-lang.org/book/ch19-03-pattern-syntax.html
    accessed: 2026-11-09
    license: "MIT OR Apache-2.0"
  - id: S3
    title: "Patterns - The Rust Reference"
    publisher: The Rust Reference (rust-lang/reference)
    url: https://doc.rust-lang.org/reference/patterns.html
    accessed: 2026-11-09
    license: "MIT OR Apache-2.0"
---
# Rust pattern syntax and refutability

**Answer:** Patterns are refutable or irrefutable. Parameters, `let`, and `for` only accept irrefutable patterns.

## Match guards and bindings

A match guard adds an `if` condition after the pattern; both must succeed for the arm to run. The `@` operator binds a variable while still testing the value against a pattern.

The Rust Reference calls a pattern refutable when it might fail to match.

## Claims

- id: C1
  claim: Patterns are either refutable or irrefutable.
  source: S1
  evidence: "Patterns come in two forms: refutable and irrefutable."
- id: C2
  claim: let and function parameters require irrefutable patterns.
  source: S1
  evidence: "Function parameters, let statements, and for loops can only accept irrefutable patterns because the program"
- id: C3
  claim: A match guard is an additional if condition on a match arm.
  source: S2
  evidence: "a match guard conditional instead. We'll talk about match guards later in the [\"Adding Conditionals"
- id: C4
  claim: The at operator creates a variable while testing a pattern.
  source: S2
  evidence: "The at operator @ lets us create a variable that holds a value at the"

- id: C5
  claim: A pattern is said to be refutable when it might not match.
  source: S3
  evidence: "A pattern is said to be refutable when it has the possibility of not being"

## Sources

- [S1] Refutability: Whether a Pattern Might Fail to Match. The Rust Project (The Rust Programming Language book). https://doc.rust-lang.org/book/ch19-02-refutability.html . License: MIT OR Apache-2.0. Accessed 2026-11-09.
- [S2] Pattern Syntax. The Rust Project (The Rust Programming Language book). https://doc.rust-lang.org/book/ch19-03-pattern-syntax.html . License: MIT OR Apache-2.0. Accessed 2026-11-09.

- [S3] Patterns - The Rust Reference. The Rust Reference (rust-lang/reference). https://doc.rust-lang.org/reference/patterns.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). The Rust Reference (rust-lang/reference): Copyright (c) 2010 The Rust Project Developers; MIT OR Apache-2.0, used under MIT (https://github.com/rust-lang/reference/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).
