doc.rust-lang.org
pub trait IndexMut<Idx>
...Side) -> &Self::Output {
println!("Accessing {index:?}-side of balance immutably");
match index {
Side::Left => &self.left,
Side::Right => &self.right,
}
}
}
impl IndexMut<Side> for Balance {
fn index_mut(&mut self, index: Side) -> &mut Self::Output {
println!("Accessing {index:?}-side of balance mutably");
match index {
Side::Left => &mut self.left,
Side...
trait
core
Stable since 1.0.0
Version 1.100.0-nightly
www.riskpeep.com
...18 - Match on the distance from the player.
19-38 - Arms for each of the distances that an object can be. Respond appropriately for each.
39-42 - This arm should never be matched. Unknown objects will be matched on 25, and other known objects will be matched on 32.
Contents...
Rust Walkthroughs
2023-02-22
~25 min read
fathy.fr
...Google recommending me Chrome, lolfor &key in input {
sequence = match sequence {
Sequence::Char => match key {
0x1b => Sequence::Escape,
0x03 => emit!(Event::Exit),
key => emit!(Event::KeyPress { key }),
},
Sequence::Escape => match key {
b'[' => Sequence::Control,
b'P' => Sequence::DeviceControl(DeviceControl::new()),
0x1b =>
emit!(Event::KeyPress { key: 0x1b }; continue),
key => {
emit!(Event...
Observations/Thoughts
2023-02-01
~12 min read
kamalmarhubi.com
...Rust has a pattern matching syntax for easily checking which variant an enum value is. If we have a variable fork_result, we can pattern match on it like this:
match fork_result {
ForkResult::Parent { child } => {
// stuff to do if we're in the parent
}
ForkResult::Child => {
// stuff do do...
Notable New Crates & Project Updates
2016-04-25
~9 min read
doc.rust-lang.org
...Fields of tuples are named using increasing numeric names matching their position in the list of types. The first field is 0. The second field is 1. And so on. The type of each field is the type of the same position in the tuple's list of types.
For...
The Rust Reference
Book
2024-01-01
~1 min read
osblog.stephenmarz.com
...That is why with print, we specify the plus '+', so that we match ONE or more. To match ZERO or more, we would use the asterisk '*'.
The second arm has $fmt:expr, which Rust will match if we provide at least one argument. In this case, this is the format...
News & Blog Posts
2019-10-15
~26 min read
dev.to
...HttpRequest) -> impl Responder {
let name = req.match_info().get("name").unwrap();
let resp = format!("hello {}", name);
HttpResponse::Ok().body(resp)
}
Enter fullscreen mode
Exit fullscreen mode
We get the name value from req's match info, then format the return string and return the response.
Now visit http://127.0...
Learn More Rust
2020-08-26
~4 min read
nbaksalyar.github.io
...match token {
SERVER_TOKEN => {
...
}
}
What does it mean? Well, the match syntax resembles the standard switch construct you can find in “traditional” imperative languages, but it has a lot more power to it. While in e.g. Java switch can match only on numbers, strings, and enums, Rust’s match...
From the Blogosphere
2015-07-13
~35 min read
woodruff.dev
...What to Expect
Real comparisons between Rust and C#
Lessons on ownership, pattern matching, traits, and lifetimes
Daily reflections from a .NET developer mindset
Daily Breakdown
Day 1: Why Rust? A C# Developer’s Journey Begins
Day 2: Installing Rust: From dotnet new to cargo new
Day 3: Hello, World...
Miscellaneous
2025-05-21
~2 min read
github.com
...Making temporary lifetime extension consistent between block expressions and
if/else blocks and match arms. This has already been implemented and approved:
https://github.com/rust-lang/rust/pull/121346
- Dropping temporaries in a match scrutinee *before* the arms are evaluated,
rather than after, to prevent deadlocks.
This has been...
RFC 3606
RFC
2024-04-02
~5 min read
tndl.me
...mismatched types expected `bool`, found `&str`
}
Switch & Match
Switch statements aren't as widely used in JavaScript as if/else, but match statements in Rust are very popular. They aren't exactly the same, and match statements have a lot of powerful uses not available to JavaScript switch statements.
// JavaScript...
Learn Standard Rust
2020-08-26
~4 min read
docs.rs
...Hamming Levenshtein - distance & normalized Optimal string alignment Damerau-Levenshtein - distance & normalized Jaro and Jaro-Winkler Sørensen-Dice The normalized versions return values between 0.0 and 1.0 , where 1.0 means an exact match. There are also generic versions of the functions for non-string inputs. Installation strsim is...
Crate
v0.11.1
2024-04-02
featherweightmusings.blogspot.co.nz
...Expr) { match e { Add(x, y) => println!("An `Add` variant: {} + {}", x, y), Or(..) => println!("An `Or` variant"), _ => println!("Something else (in this case, a `Lit`)"), }}
Each arm of the match expression matches a variant of `Expr`. All variants must be covered. The last case (`_`) covers all remaining variants, although in...
Community Updates
2014-05-24
~9 min read
github.com
A cross-platform font loading library font-kit font-kit provides a common interface to the various system font libraries and provides services such as finding fonts on the system, performing nearest-font matching, and rasterizing glyphs. Synopsis let font = SystemSource::new() .select_by_postscript_name("ArialMT") .unwrap() .load() .unwrap...
Crate
v0.14.3
2025-05-26
github.com
...Checks for `use Enum::*`.
- [match_same_arms](https://rust-lang-nursery.github.io/rust-clippy/master/index.html#match_same_arms): Checks for `match` with identical arm bodies.
- [single_match_else](https://rust-lang-nursery.github.io/rust-clippy/master/index.html#single_match_else): Checks for matches with a...
RFC 2476
RFC
2018-06-14
~30 min read
blog.burntsushi.net
...use bstr::ByteSlice;
fn main() {
let haystack = b"foo bar foo\xFF\xFFfoo quux foo";
let mut matches = vec![];
for start in haystack.find_iter("foo") {
matches.push(start);
}
assert_eq!(matches, [0, 8, 13, 22]);
}
This makes use of the ByteSlice::find_iter method. Unlike the
standard library, bstr...
Project/Tooling Updates
2022-09-14
~40 min read
c410-f3r.github.io
...When Client 2 connects, the previous matching entry is removed and a new chat is established through the insertion of each client ID into the messages collection. A new chat also triggers the awakening of the matching client (Client 1) finally returning the remote ID.
Remember when you heard that...
Rust Walkthroughs
2024-12-04
~11 min read
mercurialsolo.github.io
...The rules engine lets you define declarative policies in .claudectl.toml:[[rules]]
name = "auto-approve-tests"
match_status = ["NeedsInput"]
match_tool = ["Bash"]
match_command = ["cargo test", "npm test"]
match_project = ["api-server"]
action = "approve"
[[rules]]
name = "kill-expensive"
match_cost_above = 10.0
action = "terminate"
All conditions within a rule...
Rust Walkthroughs
2026-04-15
~11 min read
joshitech.blogspot.com
...match unsafe { FILTER.as_ref() } {
Some(filter) if !filter.is_match(args.to_string().as_slice()) => return,
_ => {}
}
// Completely remove the local logger from TLS in case anyone attempts to
// frob the slot while we're doing the logging. This will destroy any logger
// set during logging.
let mut logger = LOCAL...
New Projects
2014-12-22
~2 min read
home.expurple.me
...str> {
match db_err {
DbErr::Query(RuntimeErr::SqlxError(Error::Database(database_error))) => {
let constraint_name = database_error.constraint()?;
match database_error.kind() {
ErrorKind::UniqueViolation => humanize_unique_violation(constraint_name),
ErrorKind::ForeignKeyViolation => humanize_fk_violation(database_error.message()),
ErrorKind::CheckViolation => humanize_check_constraint_violation(constraint_name),
_ => None,
}
}
// More match arms here...
Observations/Thoughts
2026-04-15
~2 min read