crates.io
Resource path matching and router actix-router Resource path matching and router.
Crate
v0.5.5
2026-11-08
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
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
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
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
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
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
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
danclark.io
Archived: primary link replaced with an archive on 2026-09-12T11:22:01.104Z (UTC; replacement date, not snapshot date)
...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
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
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.3
2026-08-25
rust-lang.github.io
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
Conditions in constants are important for making...
RFC 2342
RFC
2018-01-11
~3 min read
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
...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
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
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