Rust Search

Find the best content on Rust, curated by the community; a search engine for Rustaceans.
andreabergia.com
...fn match_cmp(input) { if let Ok(rule) = match_eq(input) { return rule; } if let Ok(rule) = match_neq(input) { return rule; } if let Ok(rule) = match_lt(input) { return rule; } if let Ok(rule) = match_lte(input) { return rule; } if let Ok(rule) = match_gt(input) { return rule; } if...
Rust Walkthroughs 2025-08-27 ~3 min read
featherweightmusings.blogspot.co.nz
...As I said earlier, if you want to match some `x` with type `&T` you can dereference once in the match clause or match the reference in every arm of the match expression. Example: enum Enum1 {    Var1,    Var2,    Var3}fn foo(x: &Enum1) {    match *x {  // Option 1: deref here.        Var1...
Community Updates 2014-04-26 ~9 min read
www.wakunguma.com
...let val = (|(..):(_,_),(|__@_|__)|)((&*"\\",'🤔'),{}) Match fn r#match() { let val: () = match match match match match () { () => () } { () => () } { () => () } { () => () } { () => () }; assert_eq!(val, ()); } This is just matching nested match statements. Match nested if fn match_nested_if() { let val = match () { () if if if if true {true} else {false} {true} else {false} {true} else {false} => true, _ => false...
Observations/Thoughts 2025-06-25 ~12 min read
zkrising.com
...Which brings us to match. What is a match?// match is a list of patterns and what to do if they match. // // match EXPR { // PAT => EXPR // PAT => EXPR // .. // } match (a, b) { (5, x) => { // if (a,b) matches (5,x), this block is executed }, (x, 5) => { // same thing: if (a,b...
Rust Walkthroughs 2024-11-06 ~7 min read
github.com
## Summary Allow attributes on match arms. ## Motivation One sometimes wishes to annotate the arms of match statements with attributes, for example with conditional compilation `#[cfg]`s or with branch weights (the latter is the most important use). For the conditional compilation, the work-around is duplicating the whole containing function...
RFC 49 RFC 2014-03-20 ~1 min read
github.com
## Summary [summary]: #summary The current compiler implements a more expansive semantics for pattern matching than was originally intended. This RFC introduces several mechanisms to reign in these semantics without actually breaking (much, if any) extant code: - Introduce a feature-gated attribute `#[structural_match]` which can be applied to a struct...
RFC 1445 RFC 2015-02-06 ~17 min read
doc.rust-lang.org
Concise Control Flow with if let and let...else The if let syntax lets you combine if and let into a less verbose way to handle values that match one pattern while ignoring the rest. Consider the program in Listing 6-6 that matches on an Option<u8> value in...
The Rust Programming Language Book 2024-02-01 ~4 min read
github.com
## Summary [summary]: #summary Extend Rust's pattern matching exhaustiveness checks to cover the integer types: `u8`, `u16`, `u32`, `u64`, `u128`, `usize`, `i8`, `i16`, `i32`, `i64`, `i128`, `isize` and `char`. ```rust fn matcher_full(x: u8) { match x { // ok 0 ..= 31 => { /* ... */ } 32 => { /* ... */ } 33 ..= 255 => { /* ... */ } } } fn matcher_incomplete(x: u8) { match x...
RFC 2591 RFC 2018-10-11 ~3 min read
github.com
## Summary [summary]: #summary This RFC proposes to add a new kind of pattern, the **guard pattern.** Like match arm guards, guard patterns restrict another pattern to match only if an expression evaluates to `true`. The syntax for guard patterns, `pat if condition`, is compatible with match arm guard syntax, so...
RFC 3637 RFC 2024-05-13 ~12 min read
doc.rust-lang.org
...Whether a Pattern Might Fail to Match Patterns come in two forms: refutable and irrefutable. Patterns that will match for any possible value passed are irrefutable. An example would be x in the statement let x = 5; because x matches anything and therefore cannot fail to match. Patterns that can...
The Rust Programming Language Book 2024-02-01 ~2 min read
github.com
## Table of contents * [Summary][summary] * [Motivation][motivation] * [Detailed design][design] * [Syntax][syntax] * [Evolution][evolution] * [Concrete syntax][concrete-syntax] * [Expansion concerns][expansion-concerns] * [Core API][core-api] * [RegexBuilder][regexbuilder] * [Replacer][replacer] * [quote][quote] * [RegexSet][regexset] * [The `bytes` submodule][the-bytes-submodule] * [Drawbacks][drawbacks] * [Guaranteed linear time matching][guaranteed-linear-time-matching...
RFC 1620 RFC 2016-05-11 ~30 min read
notes.iveselov.info
hashtagIntroductionIn Haskell, pattern matching is mostly nice and easy. It might be made more complicated by strictness annotations (i.e. whether to evaluate sub-patterns lazily or strictly) or irrefutability annotations, but it doesn't have any special interactions with ownership, borrowing and mutability which are bread and butter of...
News & Blog Posts 2020-03-31 ~9 min read
github.com
## Summary [summary]: #summary Various changes to the match ergonomics rules: - On edition ≥ 2024, `&` and `&mut` patterns only remove a single layer of references. - On edition ≥ 2024, `mut` on an identifier pattern does not force its binding mode to by-value. - On all editions, `&` patterns can match against `&mut` references. - On...
RFC 3627 RFC 2024-05-06 ~15 min read
doc.rust-lang.org
...fn age() -> u32 { 15 } fn main() { println!("Tell me what type of person you are"); match age() { 0 => println!("I haven't celebrated my first birthday yet"), // Could `match` 1 ..= 12 directly but then what age // would the child be? // Could `match` n and use an `if` guard, but would...
Rust by Example Book 2024-01-01 ~1 min read
github.com
...Like the `for` loop before it, this construct can be transformed in a syntax-lowering pass into the equivalent `match` statement. The `expression` is given to `match` and the `pattern` becomes a match arm. If there is an `else` block, that becomes the body of the `_ => {}` arm, otherwise `_ => {}` is provided...
RFC 160 RFC 2014-08-26 ~5 min read
trifectatech.org
...when #[loop_match] and #[const_continue] are configured out (e.g. with #[cfg_attr(feature = "loop_match", loop_match)]), the code behaves like before. Benchmarks So, how much does this help? As always, it depends. Your algorithm must actually look like a loop with a match to benefit at all...
Observations/Thoughts 2025-09-10 ~9 min read
xd009642.github.io
...impl Match for BinaryStreamMatcher { fn temporal_match(&self, match_state: &mut MatchState) -> Option<bool> { let json = ValidJsonMatcher; let len = match_state.len(); let last = match_state.last(); if len == 1 && json.unary_match(last).unwrap() { match_state.keep_message(0); Some(true) } else if last.is_binary() { // We won't...
Project/Tooling Updates 2025-03-05 ~3 min read
sailor.li
...running 3 tests test accursed_match ... bench: 1,681.19 ns/iter (+/- 245.20) test optimised_match ... bench: 1,681.06 ns/iter (+/- 261.87) test regular_match ... bench: 2,339.23 ns/iter (+/- 74.51) Using arrays of [0u8; 16384]: test accursed_match ... bench: 9,373.10 ns/iter...
Rust Walkthroughs 2025-08-27 ~5 min read
adventures.michaelfbryan.com
Rust 1.26 introduced a nifty little feature called Basic Slice Patterns which lets you pattern match on slices with a known length. Later on in Rust 1.42, this was extended to allow using .. to match on “everything else”. As features go this may seem like a small addition...
Rust Walkthroughs 2021-08-18 ~3 min read
systemf.epfl.ch
...The brown lookbehind has n = 1 since it always matches exactly 1 character. m = 2 because that is the shortest matching length of aa. The blue lookbehind has n = 2 since it always matches exactly 2 characters. The surrounding lookbehinds do not contribute to the match length. m = 1 because...
Observations/Thoughts 2025-07-16 ~27 min read
"Well, let me tell you: unless your code is cooler than ICE, the compiler does not miss anything. Rust accompanies us at each step of our path, very ge..."

Search tips

Type anything to search across articles, videos (including conference talks), podcasts, research, crates, and Rust API documentation. These operators give you finer control — click an example to try it.

Find pages containing all your words. Pages where the words appear together rank higher.
Quote part of your query to keep those words together as an exact phrase within a larger search.
Wrap the whole query in quotes for a verbatim search that matches text exactly, punctuation and all — perfect for Rust syntax. Needs at least 3 characters.
Limit results to a single site. Works on its own () too. One site: per search.

Use the tabs and filters above the results to narrow by content type, publication year, and sort order.