rust-analyzer.github.io
New Features
#6645 add diagnostics for unexpandable macros.
#6666 support "go to definition" for self parameter.
#6664 show type of self on hover.
#6606 support unsafe extern block syntax.
#6618, #6621 type inference for tuple patterns with ellipsis.
#6624 check structs for match exhaustiveness.
#6631 gate autoimports behind experimental completions...
Tooling
2020-12-02
~1 min read
danube-docs.dev-state.com
Archived: primary link replaced with an archive on 2026-09-12T11:22:11.522Z (UTC; replacement date, not snapshot date)
...Subsequent producers must use the same subject:
// First producer - assigns schema subject to topic
let first = client.producer()
.with_topic("new-topic")
.with_schema_subject("user-events") // ✅ Sets topic's schema
.build();
// Second producer - must match
let second = client.producer()
.with_topic("new-topic")
.with_schema_subject("user-events") // ✅ Matches...
Project/Tooling Updates
2026-01-07
~10 min read
llogiq.github.io
...enum variants, you can also use match, but keep it simple: Only match one thing, and avoid more complex things like guard clauses:
// Don't nest patterns in match arms
match err_opt_val {
Some(Err(e)) => panic!("{e}"),
_ => (),
}
// instead, nest `match` expressions
match err_opt_val {
Some(err_val...
Observations/Thoughts
2024-04-03
~16 min read
pythonspeed.com
...def assert_matches(counts1, counts2):
"""Match A to Z counts."""
for character in 'abcdefghijklmnopqrstuvwxyz':
assert counts1[character] == counts2[character]
assert_matches(
frequency_1(TEXT),
frequency_3(TEXT)
)
Our new implementation is even faster:
Code
Elapsed microseconds
frequency_2(TEXT)
25,965.5
frequency_3(TEXT)
19,443.5
The Practice...
Observations/Thoughts
2025-07-09
~14 min read
thefuntastic.com
...This is what the match construct is all about: match item_option { Some(item) => { //Do something with resource println!("{}", item); } None => {}};It's called pattern matching and it's a switch statement, but for types. Here the Some branch is the only code path with a valid reference to item...
Observations/Thoughts
2020-10-28
~18 min read
rreverser.com
...bool> MyEnum<AllowB> {
fn is_a(&self) -> bool {
match *self {
MyEnum::A => true,
_ => false,
}
}
}
impl MyEnum<true> {
// this won't be allowed on MyEnum<false>, giving a helpful compile-time error
fn is_b(&self) -> bool {
match *self {
MyEnum::B => true,
_ => false,
}
}
}
The first thing that comes to mind is...
News & Blog Posts
2018-01-02
~5 min read
pitsidianak.is
...Instruction: {instruction:?}")
}};
}
match op {
Op::ORR => {
// Bitwise OR
// This instruction performs a bitwise (inclusive) OR of a register value and an
// immediate value, and writes the result to the destination register.
let target = match instruction.operands()[0] {
bad64::Operand::Reg {
ref reg,
arrspec: None,
} => *self.reg_to_var(reg, true...
Observations/Thoughts
2025-08-27
~10 min read
www.lpalmieri.com
...Expected range of matching incoming requests: == 1
Number of matched incoming requests: 0
'
Why is that?
Let's add a dbg! statement to our matcher to inspect the incoming request:
//! src/email_client.rs
// [...]
#[cfg(test)]
mod tests {
// [...]
impl wiremock::Match for SendEmailBodyMatcher {
fn matches(&self, request: &Request) -> bool {
// [...]
if...
Rust Walkthroughs
2021-01-20
~41 min read
blog.warp.dev
Archived: primary link replaced with an archive on 2026-09-12T11:34:45.562Z (UTC; replacement date, not snapshot date)
...SplitDirection,
) -> bool {
match self {
PaneNode::Leaf(session) => {
if *session == old_session {
*self = PaneNode::Branch(PaneBranch::new(old_session, new_session, direction));
true
} else {
false
}
}
PaneNode::Branch(branch) => branch.split(old_session, new_session, direction),
}
}
fn remove(&mut self, session_id: EntityId) -> bool {
match self {
// Leaves can only be removed from...
Rust Walkthroughs
2022-01-26
~11 min read
rust-gcc.github.io
...Zhi Heng’s work is allowing us to handle some
complex pattern matches present in core, which the compiler would
previously ignore - while Ryutaro’s contributions are adding more
complex warning checkers while removing previous false positives. Thanks
to them, the compiler is getting more correct, and gets closer and...
Project/Tooling Updates
2025-08-06
~11 min read
arzg.github.io
...How is the parser meant to manage expected_kinds if it can’t know which arm of the match is being run and which ones have been tried before? We’ll have to convert all these matches to if else chains that use Parser::at.To ensure we don’t...
Rust Walkthroughs
2020-12-23
~30 min read
arzg.github.io
...First, we’ll determine which particular operator we’re looking at:pub(super) fn expr(p: &mut Parser) {
match p.peek() {
Some(SyntaxKind::Number) | Some(SyntaxKind::Ident) => p.bump(),
_ => {}
}
let op = match p.peek() {
Some(SyntaxKind::Plus) => Op::Add,
Some(SyntaxKind::Minus) => Op::Sub,
Some(SyntaxKind::Star) => Op::Mul,
Some...
Rust Walkthroughs
2020-11-18
~27 min read
arzg.github.io
Archived: primary link replaced with an archive on 2026-09-12T11:26:22.428Z (UTC; replacement date, not snapshot date)
...We should also define a proper format for displaying Vals so we can customise how they appear:// crates/eldiro/src/val.rs
use std::fmt;
// snip
impl fmt::Display for Val {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
Self::Number(n) => write!(f, "{}", n),
Self::Unit...
Learn More Rust
2020-10-07
~13 min read
vincents.dev
...std::num::ParseIntError) -> Self {
DemoError::ParseErr(error)
}
}
impl Error for DemoError {}
impl Display for DemoError {
fn fmt(&self, f: &mut Formatter) -> Result<(), std::fmt::Error> {
match self {
DemoError::ParseErr(error) => write!(
f,
"error parsing with {}", error.to_string()
),
}
}
}
fn my_function() -> Result<(), DemoError> {
let first_input = "3^";
let my_number...
Rust Walkthroughs
2025-12-31
~9 min read
vishpat.github.io
...Rust's rich programming constructs such as enum, pattern matching, and error handling make it easy and a joy to implement this bare-bone interpreter.
Pre-requistes
To make the most out of this project, it is expected that the user is aware of the following Computer Science concepts
Lists...
Observations/Thoughts
2022-05-11
~2 min read
rust-analyzer.github.io
Rust toolchains newer than 2022-07-29 contain a proc macro server that should be compatible with macros built by the matching compiler.
Since today’s release, the server is automatically detected by and used rust-analyzer.
This means that, from now on, proc macros will keep working when the...
Project/Tooling Updates
2022-08-03
~1 min read
danube-docs.dev-state.com
Archived: primary link replaced with an archive on 2026-09-12T11:22:08.820Z (UTC; replacement date, not snapshot date)
...Pattern
Matches
"payment"
Exact match only
"ship*"
"shipping", "shipment", etc.
"eu-west-?"
"eu-west-1", "eu-west-2", etc.
"*"
Everything (same as no filter)
Glob matching is implemented with an iterative backtracking algorithm (simple_glob) that handles * and ? without regex overhead.
If a message's routing key matches no consumer...
Project/Tooling Updates
2026-04-22
~8 min read
timryan.org
...But we
lack one important aspect of Rust’s pattern matching capabilities: its
requirement that all match arms must be “exhaustive” (that is, there are no
unhandled cases).
If we matched against the FrontendMessage enum type, but we only handled the
Init and ButtonState variants, our program would fail at...
News & Blog Posts
2019-01-29
~9 min read
ettolrach.com
...In the first, we make use of pattern matching. Note how there are no cases to cover, that means there are no patterns we need to match. In the second, we make use of the function which is commonly known as absurd, whose type is 1.
A quick refresher on...
Observations/Thoughts
2026-09-09
~13 min read
cglab.ca
...Ord, V> Map<K, V> for BTreeMap<K, V> {
fn find(&self, key: &K) -> Option<&V> {
let mut cur_node = &self.root;
loop {
match cur_node.search(key) {
Found(i) => return cur_node.val(i),
GoDown(i) => match cur_node.edge(i) {
None => return None,
Some(next_node) => {
cur_node...
Observations/Thoughts
2021-02-03
~35 min read