Rust Search

Find the best content on Rust, curated by the community; a search engine for Rustaceans.
rust.code-maven.com
...Using match on Option fn match_on_option(animal: &str) { let text = "The black cat climbed the green tree"; match text.find(animal) { Some(location) => println!("Location of {animal}: {location}"), None => println!("None received - no {animal} found"), }; } Calling match_on_option("cat"); will print Location of cat: 10. Calling match...
Miscellaneous 2024-01-10 ~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
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
rust-lang.github.io
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
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
rust-lang.github.io
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. fn matcher_full(x: u8) { match x { // ok 0 ..= 31 => { /* ... */ } 32 => { /* ... */ } 33 ..= 255 => { /* ... */ } } } fn matcher_incomplete(x: u8) { match x { //~ ERROR: non-exhaustive...
RFC 2591 RFC 2018-10-11 ~3 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
rust-lang.github.io
...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 existing guards can be superceded by guard patterns without breakage. Motivation Guard patterns, unlike match arm...
RFC 3637 RFC 2024-05-13 ~12 min read
rust-lang.github.io
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 or enum...
RFC 1445 RFC 2015-02-06 ~16 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
rust-lang.github.io
Table of contents • Summary • Motivation • Detailed design • Syntax • Evolution • Concrete syntax • Expansion concerns • Core API • RegexBuilder • Replacer • quote • RegexSet • The bytes submodule • Drawbacks • Guaranteed linear time matching • Allocation • Synchronization is implicit • The implementation is complex • Alternatives • Big picture • bytes::Regex • A regex trait • Reuse some types • Unresolved questions • regex-syntax...
RFC 1620 RFC 2016-05-11 ~30 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
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
rust-lang.github.io
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 all editions...
RFC 3627 RFC 2024-05-06 ~14 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
rust-lang.github.io
...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 ~4 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 Archived: primary link replaced with an archive on 2026-09-12T17:24:55.139Z (UTC; replacement date, not snapshot date)
...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
rust-lang.github.io
...Foo(x) • The left side of a match arm, i.e. Foo(x) | Bar(x) if x > 5 • An entire match arm, i.e. Foo(x) | Bar(x) if x > 5 => 1 This RFC proposes only the first of these, but the others would be more useful in some cases...
RFC 85 RFC 2014-05-21 ~1 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
"Finally, I feel it is necessary to debunk the “*fighting the borrow checker*” legend, a story depicting the Rust compiler as a boogeyman: in my ex..."

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.
Put ! first to open the top result immediately. Quote the whole query for a literal leading bang, as in '!Send'. Bangs elsewhere, such as println!, stay literal. Browser and launcher shortcuts can invoke this directly. See search integrations.
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.