Rust Search

Find the best content on Rust, curated by the community; a search engine for Rustaceans.
doc.rust-lang.org
...For example, match is a keyword. If you try to compile the following function that uses match as its name: Filename: src/main.rs fn match(needle: &str, haystack: &str) -> bool { haystack.contains(needle) } you’ll get this error: error: expected identifier, found keyword `match` --> src/main.rs:4:4...
The Rust Programming Language Book 2024-02-01 ~3 min read
blog.cloudflare.com
...Understanding wildcards Wildcard pattern matching allows users to employ an asterisk (*) in a string to match certain patterns. For example, a single pattern like https://example.com/*/t*st can cover multiple URLs such as https://example.com/en/test, https://example.com/images/toast, and https://example.com/blog...
Project/Tooling Updates 2024-08-28 ~7 min read
github.com
...Specifically, the syntax ```rust ['ident:] while let PAT = EXPR { BODY } ``` desugars to ```rust ['ident:] loop { match EXPR { PAT => BODY, _ => break } } ``` Just as with `if let`, an irrefutable pattern given to `while let` is considered an error. This is largely an artifact of the fact that the desugared `match` ends up...
RFC 214 RFC 2014-08-27 ~2 min read
rust-lang.github.io
...This is a counterpart to if let expressions, and the pattern matching works identically, except that the value from the pattern match is assigned to the surrounding scope rather than the block’s scope. Reference-level explanations let-else is syntactical sugar for match where the non-matched case diverges...
Updates from the Rust Project 2022-09-21 ~20 min read
blog.yoshuawuyts.com
introduction logical and logical or if let-evaluation ordering closing words Introduction One of the things that stands out to me is how similar match and if..else are semantically, while being diverging a fair bit syntactically. The reasons for that seem mostly accidental, and I have a sneaking suspicion...
Observations/Thoughts 2025-04-30 ~10 min read
www.sminez.dev
...x/re/ for each match of re, run the expressions that follow y/re/ between each match of re, run the expressions that follow g/re/ if re matches, run the expressions that follow v/re/ if re does not match, run the expressions that follow For actions, the argument...
Observations/Thoughts 2025-11-19 ~16 min read
ncameron.org
...As in a match expression, => indicates matching a pattern (in this case ()) to a body (in this case println!(...);). Since our use of the macro matches the single pattern (hello!() has no arguments), we expand into the given body. The next example has some arguments, but still a single rule...
News & Blog Posts 2015-11-09 ~4 min read
estada.ch
...Argument dependant lookup in match unwrap_all() Coupling split() and join() Backwards compatibility Argument dependant lookup in match Consider this code for talking to a secondary processor: #[derive(Debug)] pub enum SecondaryProcessor { Opening(String), Ready, Writing(String), Reading(String), Closing, } When we match on it today, we have to do...
Call for Blog Posts 2020-09-23 ~4 min read
github.com
...a `match` statement takes one expression and applies multiple patterns to it until one matches, while let-else-else-chains would take one pattern and apply it to multiple expressions until one matches. This has a complexity issue with or-patterns, where expressions can _easily_ become exponential. (This is already...
RFC 3137 RFC 2021-05-31 ~21 min read
doc.rust-lang.org
...match PrintOnDrop("Matched value in final expression") { // Non-pattern-matching guards' temporaries are dropped once the // condition has been evaluated _ if PrintOnDrop("guard condition").0 == "" => (), // Pattern-matching guards' temporaries are dropped when leaving the // arm's scope _ if let "guard scrutinee" = PrintOnDrop("guard scrutinee").0 => { let _ = &PrintOnDrop("lifetime-extended temporary...
The Rust Reference Book 2024-01-01 ~16 min read
github.com
## Summary Rust's support for pattern matching on slices has grown steadily and incrementally without a lot of oversight. We have concern that Rust is doing too much here, and that the complexity is not worth it. This RFC proposes to feature gate multiple-element slice matches in the head...
RFC 164 RFC 2014-07-14 ~1 min read
www.gustavwengel.dk
...MyFood = serde_json::from_str(&json).unwrap(); // Does not work because no enum variant matches "tacos" // Error returned is: Error("data did not match any variant of untagged enum MyFood")c let json = json!( { "fruit_count": 5, "foo": 3 } ) .to_string(); let my_food: MyFood = serde_json::from_str(&json...
Rust Walkthroughs 2023-06-28 ~3 min read
dannas.name
...fn match_here(regex: &[u8], text: &[u8]) -> bool { match (regex, text) { (&[], _) => true, (&[b'$'], &[]) => true, (&[b'$'], _) => false, (&[r, b'*', ref rs @ ..], txt) => { match_star(r, rs, txt) } (&[_, ref _s @ ..], &[]) => false, (&[r, ref rs @ ..], &[t, ref ts @ ..]) if r == b'.' || r == t => { match_here(rs, ts) } _ => false, } } Finally we have the matching...
Rust Walkthroughs 2022-09-14 ~7 min read
doc.rust-lang.org
Enums and Pattern Matching In this chapter, we’ll look at enumerations, also referred to as enums. Enums allow you to define a type by enumerating its possible variants. First we’ll define and use an enum to show how an enum can encode meaning along with data. Next, we...
The Rust Programming Language Book 2024-02-01 ~1 min read
rust-lang-nursery.github.io
...It hands back the absolute path of the first match. which resolves a single best match. which_all yields every match in precedence order. That helps when a name is shadowed by more than one install. A name that is not on the PATH comes back as an Error. A...
The Rust Cookbook Book 2024-01-01 ~1 min read
siciarz.net
...fn run(matches: ArgMatches) -> Result<(), String> { // ... match matches.subcommand() { ("analyse", Some(m)) => run_analyse(m, &logger), ("verify", Some(m)) => run_verify(m, &logger), _ => Ok(()), } } fn run_analyse(matches: &ArgMatches, parent_logger: &slog::Logger) -> Result<(), String> { let logger = parent_logger.new(o!("command" => "analyse")); let input = matches.value_of("input-file...
24 Days of Rust 2016-12-20 ~6 min read
github.com
## Summary Change syntax of subslices matching from `..xs` to `xs..` to be more consistent with the rest of the language and allow future backwards compatible improvements. Small example: ```rust match slice { [xs.., _] => xs, [] => fail!() } ``` This is basically heavily stripped version of [RFC 101](https://github.com/rust-lang/rfcs/pull...
RFC 202 RFC 2014-08-15 ~1 min read
matklad.github.io
...char) -> ((), u8) { match op { '+' | '-' => ((), 9), _ => panic!("bad op: {:?}", op), } } fn postfix_binding_power(op: char) -> Option<(u8, ())> { let res = match op { '!' => (11, ()), '[' => (11, ()), _ => return None, }; Some(res) } fn infix_binding_power(op: char) -> Option<(u8, u8)> { let res = match op { '=' => (2, 1), '?' => (4, 3), '+' | '-' => (5, 6), '*' | '/' => (7, 8), '.' => (14, 13...
News & Blog Posts 2020-04-21 ~18 min read
matklad.github.io
...char) -> ((), u8) { match op { '+' | '-' => ((), 9), _ => panic!("bad op: {:?}", op), } } fn postfix_binding_power(op: char) -> Option<(u8, ())> { let res = match op { '!' => (11, ()), '[' => (11, ()), _ => return None, }; Some(res) } fn infix_binding_power(op: char) -> Option<(u8, u8)> { let res = match op { '=' => (2, 1), '?' => (4, 3), '+' | '-' => (5, 6), '*' | '/' => (7, 8), '.' => (14, 13...
News & Blog Posts 2020-05-05 ~18 min read
blog.knoldus.com
...i32) -> i32 { match number { 2 => number, _ => number + 1 , } } const DIGIT: i32 = 9; const RESULT: i32 = even(DIGIT); const RESULT_MATCH: i32 = even_no(DIGIT); fn main() { println!("The result of const function with if statement: {}", RESULT); println!("The result of const function with match statement: {}", RESULT_MATCH); } Output: The result...
Learn Simple Rust 2020-09-30 ~2 min read
"It feels like being part of a village that learns to love the dragon it battles."

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.