Rust Search

Find the best content on Rust, curated by the community; a search engine for Rustaceans.
github.com
...Two incredibly common patterns in particular stand out: ``` match map.entry(key) => { Entry::Vacant(entry) => { entry.insert(1); }, Entry::Occupied(entry) => { *entry.get_mut() += 1; }, } ``` ``` match map.entry(key) => { Entry::Vacant(entry) => { entry.insert(vec![val]); }, Entry::Occupied(entry) => { entry.get_mut().push(val); }, } ``` This code is noisy, and is...
RFC 921 RFC 2015-03-01 ~2 min read
dev.to
...either match everything, or using combinators: ok(), unwrap_or(), and_then(), etc, etc... I prefer to match and follow strict indentation, so that it is clearer at the end what we are matching for. We use indentation to help understanding the patterns of Ok(_)/Err(_) and Some(_)/None. Maybe it...
Rust Walkthroughs 2020-12-02 ~18 min read
mcmah309.github.io
...Option<f64>) { self.ranking_score_threshold = threshold; } } impl HasTermsMatchingStrategy for KeywordSearch<'_> { fn get_terms_matching_strategy(&self) -> &TermsMatchingStrategy { &self.terms_matching_strategy } fn set_terms_matching_strategy(&mut self, strategy: TermsMatchingStrategy) { self.terms_matching_strategy = strategy; } } impl HasScoringStrategy for KeywordSearch<'_> { fn get_scoring_strategy(&self) -> &ScoringStrategy { &self.scoring_strategy } fn...
Rust Walkthroughs 2025-06-11 ~17 min read
corentin-core.github.io
...let list = hlist![1i32, "hello", 3.14f64]; let (matched, leftover) = list.sculpt::<HList!(f64, i32), _>(); // matched : HList!(3.14f64, 1i32) // leftover : HList!("hello") The compiler walks the source HList, plucks each requested type by recursing until it finds a match, builds the matched tuple, returns what’s left. Two failure...
Rust Walkthroughs 2026-06-24 ~16 min read
depth-first.com
...pub enum Element { Ac, B, Br, // ... } pub enum Error { Character(usize) } pub fn element(scanner: &mut Scanner) -> Result<Option<Element>, Error> { match scanner.peek() { Some('A') => { scanner.pop(); match scanner.peek() { Some('c') => { scanner.pop(); Ok(Some(Element::Br)) }, _ => Err(Error::Character(scanner.cursor())) } }, Some('B') => { scanner.pop(); match scanner...
Rust Walkthroughs 2021-12-22 ~12 min read
doc.rust-lang.org
...Condition operands must be either an [Expression] with a boolean type or a conditional let match. If all of the condition operands evaluate to true and all of the let patterns successfully match their scrutinees, then the loop body block executes. After the loop body successfully executes, the condition operands...
The Rust Reference Book 2024-01-01 ~8 min read
rreverser.com
...Macros currently don't allow matching literals, and expr won't work for us because it can accidentally match sequence like 2 + 3 ... instead of taking just a single number, so we'll resort to tt - a generic token matcher that matches only one token tree (whether it's a...
News & Blog Posts 2018-01-16 ~13 min read
doc.rust-lang.org
...The scrutinee is the expression being matched on in the if let expression. Migration It is always safe to rewrite if let with a match. The temporaries of the match scrutinee are extended past the end of the match expression (typically to the end of the statement), which is the...
The Rust Edition Guide Book 2024-01-01 ~3 min read
www.sheshbabu.com
...Ignore the error Terminate the program Use a fallback value Bubble up the error Bubble up multiple errors Match boxed errors Libraries vs Applications Create custom errors Bubble up custom errors Match custom errors Ignore the errorLet’s start with the simplest scenario where we just ignore the error. This...
Learn Standard Rust 2020-08-04 ~11 min read
crates.io
Resource path matching and router actix-router Resource path matching and router.
Crate v0.5.4 2026-02-18
crates.io
...i32) -> impl Iterator<Item = i32> { match x { 0 => 1..10, #[nested] _ => match x { 1 => vec![5, 10].into_iter(), _ => 0..=x, }, } } See documentation for more details. Supported traits #[enum_derive] implements the supported traits and passes unsupported traits to #[derive] . #[enum_derive] supports many of the standard library traits and...
Crate v0.8.10 2026-07-25
rustc-dev-guide.rust-lang.org
...for<'a> Foo<&'a isize> and we match this impl. What obligation is generated as a result? We want to get Baz: for<'a> Bar<&'a isize>, but how does that happen? After the matching, we are in a position where we have a placeholder substitution like X => &'0 isize...
Guide to Rustc Development Book 2024-01-01 ~3 min read
doc.rust-lang.org
...u32) -> u32 { let mut acc = 0; for i in 0..up_to { // Notice that the return type of this match expression must be u32 // because of the type of the "addition" variable. let addition: u32 = match i%2 == 1 { // The "i" variable is of type u32, which is perfectly fine...
Rust by Example Book 2024-01-01 ~1 min read
doc.rust-lang.org
...the parser tries alternatives left to right and takes the first that matches. If an alternative fails partway through a sequence, the parser normally backtracks and tries the next alternative. The cut operator (^) prevents this. Once every expression to the left of ^ in a sequence has matched, the rest of...
The Rust Reference Book 2024-01-01 ~3 min read
crates.io
A collection of useful testing assertions and utilities assert_matches A rust library for pattern-matching assertions
Crate v2.0.4 2025-11-25
github.com
...Note that the target ABI cannot currently be `#[cfg]`-ed against, so a `build.rs` is still necessary to match all target components. ## Guide-level explanation [guide-level-explanation]: #guide-level-explanation This would act like existing `target_*` configurations (except `target_feature`) but match against all components. ```rust #[cfg(target...
RFC 3239 RFC 2020-09-27 ~2 min read
rustc-dev-guide.rust-lang.org
...The result looks like this: $ perf focus '{do_mir_borrowck}' --tree-callees --tree-min-percent 3 Matcher : {do_mir_borrowck} Matches : 577 Not Matches: 746 Percentage : 43% Tree | matched `{do_mir_borrowck}` (43% total, 0% self) : | rustc_borrowck::nll::compute_regions (20% total, 0% self) : : | rustc_borrowck::nll::type_check...
Guide to Rustc Development Book 2024-01-01 ~9 min read
doc.rust-lang.org
pub fn starts_with<P>(&self, pat: P) -> bool
str::starts_with — Returns true if the given pattern matches a prefix of this string slice. Returns false if it does not. The pattern can be a &str, in which case this function will return true if the &str is a prefix of this string slice. The pattern can also...
method core Stable since 1.0.0 Version 1.100.0-nightly
blog.knoldus.com
...extern crate movie_genres; use movie_genres::Genres; fn main() { let genres = Genres::Horror; match genres { Genres::Horror => println!("Horror Movie!!"), Genres::Comedy => println!("Comedy Movie!!"), Genres::Romance => println!("Romance Movie!!"), } } Now if we hit cargo run, we will get a compilation error. Now add wildcard arm in match expression...
Learn Standard Rust 2020-08-04 ~1 min read
github.com
...In particular, at the time that mailing list thread was created, the code match `match x {} ...` would be parsed as `match (x {}) ...`, not as `(match x {}) ...` (see [Rust PR 5137]); likewise, `if x {}` would be parsed as an if-expression whose test component is the struct literal `x {}`. Thus, at...
RFC 218 RFC 2014-08-28 ~12 min read
"Language stability is not just about semver compatibility. It's also about not burdening developers to have to make new decisions when looking at old ..."

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.