Match statement
A match statement is a programming or query construct that compares a value or pattern against alternatives to select corresponding behavior or results.
Rust Servers, Services, and Apps
A match statement is a Rust control-flow construct that selects behavior by matching a value against patterns.
- How it is used
- Uses pattern matching to handle successful and failed computations in Rust error-handling and Actix Web request paths.
- How deep it goes
- Explains worked Result branches, custom error formatting, and HTTP propagation before introducing the shorter ? operator.
- Examples
- Uses integer parsing, squaring, custom parse and I/O errors, and an Actix Web file-reading handler.
- What you can do after
- Apply match statements to branch on Rust Result values and propagate failures through Actix Web handlers.
Read how Rust Servers, Services, and Apps explains match statement →
Refactoring to Rust
A match expression is Rust's pattern-matching control-flow expression that selects and evaluates an arm based on a value's structure or variant.
- How it is used
- Uses match to turn FizzBuzz results into output and to handle success or propagate errors.
- How deep it goes
- Explains enum-arm selection, payload binding, and match as a value that can return early on Err.
- Examples
- Uses FizzBuzz variants, including a data-carrying NotDivisible variant, and matches Result with an early error return.
- What you can do after
- Apply it via Rust to dispatch enum variants, bind variant data, and handle Result errors with explicit early returns.
Related concepts
- pattern matchingimplements · Pattern matching is the process of comparing data or values with specified or learned patterns to identify correspondence, conformity, or a matching case.
- graph patternuses · A graph pattern is a declarative representation of nodes, relationships, and property constraints used to describe graph structures to match.
- statementkind of · A statement is a syntactic program construct that performs an action, declaration, or control operation without necessarily producing an expression value.
- case statementequivalent to · A case or switch construct is a conditional control-flow construct that selects a branch or result from alternatives by matching a value or testing conditions.
- Cypherpart of · Cypher is a declarative graph query language for expressing patterns and retrieving, creating, or modifying property-graph data.
- result typeuses · A type that represents an operation’s outcome as either a successful value or a failure value.
These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.

