Rust Search

Find the best content on Rust, curated by the community; a search engine for Rustaceans.
siciarz.net
...So let's use pattern matching to find color by name: pub fn find_color(name: &str) -> Option<Color> { match name.to_lowercase().as_str() { "amber" => Some(Color { r: 255, g: 191, b: 0 }), // hundreds of other names... "zinnwaldite brown" => Some(Color { r: 44, g: 22, b: 8 }), _ => None, } } The...
24 Days of Rust 2016-12-13 ~3 min read
docs.rs
path-tree is a lightweight high performance HTTP request router for Rust path-tree A lightweight high performance HTTP request router for Rust Parameters Syntax Pattern Kind Description :name Normal Matches a path piece, excludes / :name? Optional Matches an optional path piece, excludes / /:name?/ /:name? OptionalSegment Matches an optional path...
Crate v0.8.3 2025-03-23
lwn.net
...This makes it easier to write rules that match two different call sites separated by some arbitrary code. Matching a pattern that contains an ellipsis requires considering different potential matches, which means considering multiple alternatives, so it is a form of disjunction. Previously, Coccinelle only permitted disjunctions of expressions; now...
Project/Tooling Updates 2024-10-02 ~4 min read
crates.io
proc macro for generating match block for alphabets, please dont use this. its slow and extremly likely to not be what you are looking for.
Crate v0.1.2 2026-01-14
danclark.io
...A simple, ergonomic API to define mocks in Rust First-class support for streaming and gRPC A minimal set of "matchers" to match requests to mock responses by method, path, and body The result of this experiment is mocktail, which I am happy to share with the community, in case...
Project/Tooling Updates 2025-03-19 ~2 min read
viruta.org
...replace AcceptLanguage::any_matches -> bool with false rsvg/src/accept_language.rs:136:9: replace AcceptLanguage::any_matches -> bool with true Now look at the corresponding lines in the source: ... impl AcceptLanguage { 135 fn any_matches(&self, tag: &LanguageTag) -> bool { 136 self.iter().any(|(self_tag, _weight)| tag.matches(self...
Rust Walkthroughs 2025-12-03 ~9 min read
dev.to
...pattern matching. The branches of a "match" block execute only if the input to the match matches the left hand side and if it does any variables declared within the match store the value in that place of the structure. This is hard to explain but intuitive to write and...
Learn Standard Rust 2020-09-04 ~6 min read
alex.draftist.io
...We also need to handle every state without accidentally forgetting one.Pattern matching lets us consider each possibility separately. In Rust, a match must be exhaustive: the compiler rejects it unless every possible case is covered.For example, we have three possible results from parse_port: a valid port, a...
Observations/Thoughts 2026-08-05 ~10 min read
docs.rs
...Usage wild::args() is a drop-in replacement for std::env::args() . [dependencies] wild = "2" fn main() { let args = wild::args(); println!("The args are: {:?}", args.collect::<Vec<_>>()); } Usage with Clap let matches = clap::App::new("your_app") .arg(…) .arg(…) .arg(…) // .get_matches(); change to: .get_matches_from(wild::args());
Crate v2.2.1 2024-01-27
doc.rust-lang.org
...fn main() { let names = vec!["Bob", "Frank", "Ferris"]; for name in names.iter() { match name { &"Ferris" => println!("There is a rustacean among us!"), // TODO ^ Try deleting the & and matching just "Ferris" _ => println!("Hello {}", name), } } println!("names: {:?}", names); } • into_iter - This consumes the collection so that on each iteration the exact...
Rust by Example Book 2024-01-01 ~2 min read
durch.github.io
...let new_token = async { match fetcher.fetch_token().await { Ok(token) => token, Err(e) => panic!(e) } }; assert_ne!(token, new_token); Ok(()) }
Crate v0.17.0 2025-12-09
doc.rust-lang.org
pub fn strip_circumfix<P, S>(&self, prefix: P, suffix: S) -> Option<&str>
...Unlike trim_start_matches and trim_end_matches, this method removes both the prefix and suffix exactly once. If the string does not start with prefix, does not end with suffix, or the prefix and suffix overlap in the string, returns None. Each pattern can be a &str, char, a...
method core Stable since 1.98.0 Version 1.100.0-nightly
erk.dev
...Is there a Clippy lint to enforce exhaustive structural pattern matching? The examples they gave were the following: Bad Case let Foo { bar, .. } = foo;match bar { Bar::A { a, b, .. } => ..., Bar::B { a, .. } => ...,} Good Case let Foo { bar, baz: _ } = foo;match bar { Bar::A { a, b, c: _ } => ..., Bar::B { a...
Rust Walkthroughs 2025-08-27 ~13 min read
doc.rust-lang.org
pub macro unreachable!
...Examples Match arms: fn foo(x: Option<i32>) { match x { Some(n) if n >= 0 => println!("Some(Non-negative)"), Some(n) if n < 0 => println!("Some(Negative)"), Some(_) => unreachable!(), // compile error if commented out None => println!("None") } } Iterators: fn divide_by_three(x: u32) -> u32 { // one of the poorest implementations...
macro core Stable since 1.0.0 Version 1.100.0-nightly
www.youtube.com
...can't know which match arm you're gonna take yeah exactly exactly that was my point was the match we have the thing we were discussing earlier kind of seems to break that assumption because currently there's always a use of the match right currently it is yes...
Video 2021-01-25
doc.rust-lang.org
pub fn rsplit_terminator<P>(&self, pat: P) -> RSplitTerminator<'_, P>
str::rsplit_terminator — Returns an iterator over substrings of self, separated by characters matched by a pattern and yielded in reverse order. The pattern can be a &str, char, a slice of chars, or a function or closure that determines if a character matches. Equivalent to split, except that the...
method core Stable since 1.0.0 Version 1.100.0-nightly
github.com
## Summary [summary]: #summary Enable `if` and `match` during const evaluation and make them evaluate lazily. In short, this will allow `if x < y { y - x } else { x - y }` even though the else branch would emit an overflow error for unsigned types if `x < y`. ## Motivation [motivation]: #motivation Conditions in constants...
RFC 2342 RFC 2018-01-11 ~3 min read
thesquareplanet.com
...You may be tempted to write code like this let mut v = foo(); match v { Enum::Bar(ref mut x) => { x += 1; }, Enum::Baz(ref mut y) => { y -= 1; }, _ => (), // needed to make pattern exhaustive }; v But match can make this much nicer: match foo() { Enum::Bar(x) => Enum::Bar(x...
Blog Posts 2016-10-25 ~8 min read
doc.rust-lang.org
pub type Result<T> = crate::result::Result<T, Box<dyn Any + Send + 'static>>
...or in case the thread is intended to be a subsystem boundary that is supposed to isolate system-level failures, match on the Err variant and handle the panic in an appropriate way A thread that completes without panicking is considered to exit successfully. Examples Matching on the result of...
type_alias std Stable since 1.0.0 Version 1.100.0-nightly
bal-e.org
...you need to match the input (a, b) against the match arms in foo (“parsing”); then you need to compute the output by filling in meta-variables in the match arm body (“transcribing”). r-a’s mbe/expander/matcher.rs, which implements the parsing step, has a top-level comment...
Rust Walkthroughs 2026-05-06 ~10 min read
"As usual, the borrow checker is correct: we are doing memory crimes."

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.