Rust Search

Find the best content on Rust, curated by the community; a search engine for Rustaceans.
doc.rust-lang.org
...let reference = &4; match reference { // If `reference` is pattern matched against `&val`, it results // in a comparison like: // `&i32` // `&val` // ^ We see that if the matching `&`s are dropped, then the `i32` // should be assigned to `val`. &val => println!("Got a value via destructuring: {:?}", val), } // To avoid the `&`, you dereference...
Rust by Example Book 2024-01-01 ~1 min read
doc.rust-lang.org
Or patterns in macro-rules Summary • How patterns work in macro_rules macros changes slightly: • $_:pat in macro_rules now matches usage of | too: e.g. A | B. • The new $_:pat_param behaves like $_:pat did before; it does not match (top level) |. • $_:pat_param is available in all editions...
The Rust Edition Guide Book 2024-01-01 ~2 min read
iximiuz.com
...MatchOp, } /// Parses a label matching operation. /// /// ``` /// # use nom_parser_example::naive::{label_match, LabelMatch, MatchOp}; /// # /// # fn main() { /// assert_eq!( /// label_match(r#"foo=="bar""#), /// Ok(("", LabelMatch { label: "foo", value: "bar", op: MatchOp::Eql })) /// ); /// assert_eq!( /// label_match(r#"foo!~"2..""#), /// Ok(("", LabelMatch { label: "foo", value: "2..", op: MatchOp::NeqRe })) /// ); /// # } /// ``` pub...
Rust Walkthroughs 2021-07-28 ~15 min read
rust-lang.github.io
Summary Rust currently forbids pattern guards on match arms with move-bound variables. Allowing them would increase the applicability of pattern guards. Motivation Currently, if you attempt to use guards on a match arm with a move-bound variable, e.g. struct A { a: Box<int> } fn foo(n: int...
RFC 107 RFC 2014-06-05 ~3 min read
manishearth.github.io
...u8 = ...; // A_const let A @ _ = ...; // A_let match .. { A => ...; // A_match } What happens here is that constants and variables occupy the same namespace. So A_let shadows A_const here, and when we attempt to match, A_match is resolved to A_let and rejected (since you can’t match...
News & Blog Posts 2018-04-17 ~6 min read
doc.rust-lang.org
...macro_rules! example { ($e:expr) => { println!("first rule"); }; (const $e:expr) => { println!("second rule"); }; } fn main() { example!(const { 1 + 1 }); } Here, in the 2021 Edition, the macro will match the second rule. If earlier editions had changed expr to match the newly introduced const expressions, then it would match the...
The Rust Edition Guide Book 2024-01-01 ~1 min read
rust-leipzig.github.io
...Matches Regarding the found matches I found some deviations. At first, the libraries oniguruma and tre do not support Unicode category expressions like \p{Sm}. This expression matches all mathematical symbols like = or |. The Rust regex crate matches additionally the symbol ∞. Hyperscan returns more matches than other engines, e.g...
News & Blog Posts 2017-04-04 ~7 min read
rust-lang.github.io
...On floats are raw pointers, pattern matching behaves like ==, which means in particular that the value -0.0 matches the pattern 0.0, and NaN values match no pattern (except for wildcards). Breaking changes This RFC breaks code that compiles today, but only code that already emits a future compatibility...
RFC 3535 RFC 2023-11-19 ~17 min read
rust-lang.github.io
...maybe_label FOR top_pat IN expr_nostruct block ; For match expressions we now have: expr_match : MATCH expr_nostruct '{' match_clause* nonblock_match_clause? '}' ; match_clause : nonblock_match_clause ',' | block_match_clause ','? ; nonblock_match_clause : match_arm (nonblock_expr | block_expr_dot) ; block_match_clause : match_arm (block | block...
RFC 2535 RFC 2018-08-29 ~18 min read
gaultier.github.io
...But not for match. Alright, so after some searching around, I came up with this mouthful of a syntax: Rust1 let value = match left.try_into() { 2 Ok(v) => v, 3 Err::<_, TryFromSliceError>(err) => { 4 // [...] 5 } 6 }; Which works! And the same syntax can be applied to the Ok branch...
Rust Walkthroughs 2025-02-12 ~5 min read
adventures.michaelfbryan.com
...Matcher> Matcher for FallingEdge<M> { fn matches_event(&mut self, event: &Event<'_>) -> bool { let current_is_matched = self.inner.matches_event(event); let is_falling_edge = self.previous_was_matched && !current_is_matched; self.previous_was_matched = current_is_matched; is_falling_edge } } For convenience we can add a combinator...
News & Blog Posts 2020-02-11 ~14 min read
beeb.li
...For each match, we see a couple of lines of context with line numbers above and below. The selected match is indicated by a yellow chevron in the gutter. Each individual match can be toggled to be skipped during replacement with s. The match appears in dimmed text if skipped...
Project/Tooling Updates 2026-05-20 ~16 min read
blog.sheerluck.dev
...And we matched on it: let regex = match Regex::new(pattern) { Ok(r) => r, Err(e) => { eprintln!("Invalid pattern: {}", e); std::process::exit(1); } }; Now we're going to go much deeper. Pattern Matching on Result Just like Option, you can match on Result: match result { Ok(value) => println!("success...
Rust Walkthroughs 2026-05-06 ~27 min read
home.expurple.me
Table of ContentsThe “Error Handling” seriesLibrary vs application needsDon’t use one big enum for everythingModularityPrecise signaturesFlat vs nested enumsFlat enumsNested enumsWorkarounds for pattern matching nested enumsOther tipsWhen to reuse an error type between multiple functionsWhere to put error typesDon’t create one-variant enumsnon_exhaustiveNaming error variantsPrivacy of fieldsMixing...
Rust Walkthroughs 2026-01-28 ~12 min read
morestina.net
Let’s say you need to match the same regex across a large number of strings – perhaps you’re applying a grep-like filter to data generated or received by your program. This toy example demonstrates it by matching a regex against half a billion strings: use regex::Regex; lazy...
Observations/Thoughts 2022-10-26 ~3 min read
rust-lang.github.io
...An individual #[cfg(...)] attribute "matches" if all of the contained cfg patterns match the compilation environment, and an item preserved if it either has no #[cfg(...)] attributes or any of the #[cfg(...)] attributes present match. This is problematic for several reasons: • It is excessively verbose in certain situations. For example...
RFC 194 RFC 2014-08-09 ~3 min read
rust-lang.github.io
Summary Change pattern matching on an &mut T to &mut <pat>, away from its current &<pat> syntax. Motivation Pattern matching mirrors construction for almost all types, except &mut, which is constructed with &mut <expr> but destructured with &<pat>. This is almost certainly an unnecessary inconsistency. This can and does lead...
RFC 179 RFC 2015-01-04 ~2 min read
aarol.dev
...Key) -> &'static str { use Key::*; match *LANG { Lang::En => match key { battery_remaining => "remaining", no_adapter_found => "No headphone adapter found", view_logs => "View logs", view_updates => "View updates", quit_program => "Close", device_charging => "(Charging)", device_disconnected => "(Disconnected)", version => "Version", }, Lang::Fi => match key { battery_remaining => "jäljellä", no_adapter_found...
Observations/Thoughts 2025-05-14 ~2 min read
rust-analyzer.github.io
...SSR now matches paths based on whether they resolve to the same thing instead of whether they’re written the same. So foo() won’t match foo() if it’s a different function foo(), but will match bar::foo() if it’s the same foo. Paths in the replacement will...
Tooling 2020-07-28 ~1 min read
jdrouet.github.io
...Option<AttributeIndex>, filter: &TextFilter, ) -> HashMap<EntryIndex, f64> { let matching_terms = match filter { TextFilter::StartsWith { prefix } => self.trienodes().search(prefix), TextFilter::Matches { value } => self.trigrams().search(value), TextFilter::Equals { value } => self.inner.get_term(value).into_iter(), }; let matching_entries = self.reduce_matches(attribute, matching_terms) self.compute_scores(attribute, matchings...
Rust Walkthroughs 2025-04-16 ~13 min read
"Rust is difficult because most programmers abuse shared mutable state and Rust makes you sacrifice your first-born to be able to do it."

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.