request-for-explanation.github.io
Episode List
June 19, 2017
This week we look at RFC 2005
"Match Ergonomics Using Default Binding Modes"
MP3
OGG
MPEG-4
RFC 1944, the predecessor of #2005
Carol Nichols
Alexis Beingessner
Manish Goregaokar
Transcription courtesy of wirelyre! Thank you! <3
Carol Nichols: Hi everyone. Welcome to the inaugural episode...
News & Blog Posts
2017-06-27
~14 min read
ntietz.com
...The struct tells us where a match is.
Our first function finds our longest partial match that's within our digit limit.
pub struct Location {
pub offset: usize,
pub length: usize,
}
pub fn find_pi_match(msg: &[u8], limit: usize) -> Option<Location> {
let mut best_match: Option<Location> = None;
let...
Observations/Thoughts
2024-03-20
~6 min read
blog.burntsushi.net
...Instead, they have
leftmost-longest semantics, where the longest possible match always wins. In
this case, | is a commutative operator. Some other regex engines, such as
Hyperscan, implement “report all matches” or “earliest match” semantics. In
that case, abc|a would match both a and abc in the haystack abc...
Project/Tooling Updates
2023-07-12
~105 min read
github.com
...pub enum Equality {
AreEqual,
AreUnequal,
}
pub trait PartialEq {
fn partial_eq(&self, other: &Self) -> Option<Equality>;
fn eq(&self, other: &Self) -> bool {
match self.partial_eq(other) {
Some(AreEqual) => true,
_ => false,
}
}
fn neq(&self, other: &Self) -> bool {
match self.partial_eq(other) {
Some(AreUnequal) => true,
_ => false,
}
}
}
```
RFC 100
RFC
2014-06-01
~2 min read
hurl.dev
...GET https://sample.org/hello
HTTP/1.0 200
[Asserts]
jsonpath "$.date" matches "^\\d{4}-\\d{2}-\\d{2}$"
jsonpath "$.name" matches "Hello [a-zA-Z]+!"
In 1.6.0, we’ve added regex literal for matches:
GET https://sample.org/hello
HTTP/1.0 200
[Asserts]
jsonpath "$.date" matches...
Project/Tooling Updates
2022-02-23
~1 min read
docs.rs
Support for matching file paths against Unix shell style patterns.
glob Support for matching file paths against Unix shell style patterns. Documentation Usage To use glob , add this to your Cargo.toml : [dependencies] glob = "0.3.2" Examples Print all jpg files in /media/ and all of its subdirectories. use...
Crate
v0.3.4
2026-07-21
doc.rust-lang.org
pub fn find<P>(&self, pat: P) -> Option<usize>
str::find — Returns the byte index of the first character of this string slice that matches the pattern.
Returns None if the pattern doesn't match.
The pattern can be a &str, char, a slice of chars, or a function or closure that determines if a character matches.
Examples
Simple...
method
core
Stable since 1.0.0
Version 1.100.0-nightly
blog.sheerluck.dev
...Match
match is Rust's pattern matching construct. It compares a value against a series of patterns and executes the code for the first pattern that matches:
let x = 3;
match x {
1 => println!("one"),
2 => println!("two"),
3 => println!("three"),
4 => println!("four"),
_ => println!("other")
}
Each line inside the...
Rust Walkthroughs
2026-04-08
~18 min read
heroiclabs.com
...Any user can participate in matches with other users. Users can create, join, and leave matches with messages sent from clients. A match exists on the server until its last participant has left.
Any data sent through a match is immediately routed to all other participants. The matches are kept...
Rust Walkthroughs
2021-04-21
~19 min read
www.newrustacean.com
...Pattern matching, with a focus on using them with enumerated types and
some discussion about how they differ from switch blocks in C-like
languages.
Using the Option and Result enumerated types with pattern matching
to provide meaningful returns from functions safely.
§Order
There is a specific order to the...
News & Blog Posts
2015-10-26
~1 min read
crates.io
...String, } } // disabled variant is matched let config = toml::from_str::<Config>(r#" [feature] enabled = false "#).unwrap(); assert!(matches!(config.feature, FeatureConfig::Disabled { .. })); // if the type used `enabled: bool`, this would cause issues and require Option<_> wrappers plus // further validation... instead an error is returned immediately regarding the missing fields let...
Crate
v0.1.5
2026-07-21
crates.io
...States can defer an event to their superstate by returning the Super outcome. #[state(superstate = "blinking")] fn led_on(event: &Event) -> Outcome<State> { match event { Event::TimerElapsed => Transition(State::led_off()), Event::ButtonPressed => Super } } #[superstate] fn blinking(event: &Event) -> Outcome<State> { match event { Event::ButtonPressed => Transition(State::not_blinking()), _ => Super...
Crate
v0.4.0
2025-07-05
adventures.michaelfbryan.com
...The error message is telling us that it
matched the function signature, then when trying to match the rest of the
input (of which there is none) it didn’t have enough tokens.
The solution is easy enough, just add a base case which matches exactly nothing.
// src/lib.rs...
News & Blog Posts
2020-06-23
~29 min read
crates.io
...States can defer an event to their superstate by returning the Super outcome. #[state(superstate = "blinking")] fn led_on(event: &Event) -> Outcome<State> { match event { Event::TimerElapsed => Transition(State::led_off()), Event::ButtonPressed => Super } } #[superstate] fn blinking(event: &Event) -> Outcome<State> { match event { Event::ButtonPressed => Transition(State::not_blinking()), _ => Super...
Crate
v0.4.1
2025-07-05
doc.rust-lang.org
...Option<Food>) -> Option<Peeled> {
match food {
Some(food) => Some(Peeled(food)),
None => None,
}
}
// Chopping food. If there isn't any, then return `None`.
// Otherwise, return the chopped food.
fn chop(peeled: Option<Peeled>) -> Option<Chopped> {
match peeled {
Some(Peeled(food)) => Some(Chopped(food)),
None => None,
}
}
// Cooking food. Here, we showcase...
Rust by Example
Book
2024-01-01
~1 min read
www.howtocodeit.com
...The underscores are matched by $skip, and the expression is matched by $e.
Let's break this down.Private macro rules in Rust@ {...} isn't some esoteric Rust syntax you haven't seen before. It's not valid Rust at all! It's merely a pattern of tokens, matched by...
Rust Walkthroughs
2024-07-10
~16 min read
rustc-dev-guide.rust-lang.org
...If there are multiple matching candidates in a group, we report an error, except that multiple impls of the same trait are treated as a single match. Otherwise we pick the first match we find.
In the case of our example, the first step is Rc<Box<[T; 3]>>, which...
Guide to Rustc Development
Book
2024-01-01
~3 min read
doc.rust-lang.org
...use std::num::ParseIntError;
fn multiply(first_number_str: &str, second_number_str: &str) -> Result<i32, ParseIntError> {
let first_number = match first_number_str.parse::<i32>() {
Ok(first_number) => first_number,
Err(e) => return Err(e),
};
let second_number = match second_number_str.parse::<i32>() {
Ok(second_number) => second_number...
Rust by Example
Book
2024-01-01
~1 min read
vojtechkral.github.io
...fn exprs() {
fn make_token(s: &'static str) -> Result<Token, ()> {
Ok(Token(s))
}
match make_token("matched token") {
Ok(_) => println!("match arm"),
Err(_) => unreachable!(),
}
println!("after match");
if let Ok(_) = make_token("if let token") {
println!("if let body");
}
println!("after if let");
if make_token("if token").is_ok...
Observations/Thoughts
2020-09-30
~7 min read