www.sminez.dev
...x/re/ for each match of re, run the expressions that follow
y/re/ between each match of re, run the expressions that follow
g/re/ if re matches, run the expressions that follow
v/re/ if re does not match, run the expressions that follow
For actions, the argument...
Observations/Thoughts
2025-11-19
~16 min read
ncameron.org
...As in a match expression, => indicates matching a pattern (in this case ()) to a body (in this case println!(...);). Since our use of the macro matches the single pattern (hello!() has no arguments), we expand into the given body.
The next example has some arguments, but still a single rule...
News & Blog Posts
2015-11-09
~4 min read
github.com
...Overview Daachorse (pronounced "dark horse") is a crate for fast multiple pattern matching using the Aho-Corasick algorithm , running in linear time over the length of the input text. This crate uses the compact double-array data structure for implementing the pattern match automaton for time and memory efficiency. The...
Crate
v5.1.0
2026-10-18
crates.io
...To add a literal ] do "[]abc]" {e} = doesn't return a value, but matches end of line. Use this if you don't want to ignore potential extra characters at end of input. Examples: {[0-9ab]} = match 0-9 or a or b {[^,.]} = match anything but , or . {/.../} = return regex inside...
Crate
v0.2.6
2021-02-21
estada.ch
...Argument dependant lookup in match
unwrap_all()
Coupling split() and join()
Backwards compatibility
Argument dependant lookup in match
Consider this code for talking to a secondary processor:
#[derive(Debug)]
pub enum SecondaryProcessor {
Opening(String),
Ready,
Writing(String),
Reading(String),
Closing,
}
When we match on it today, we have to do...
Call for Blog Posts
2020-09-23
~4 min read
doc.rust-lang.org
pub fn binary_search_by<'a, F>(&'a self, f: F) -> Result<usize, usize>
...If the value is found then Result::Ok is returned, containing the index of the matching element. If there are multiple matches, then any one of the matches could be returned. If the value is not found then Result::Err is returned, containing the index where a matching element could...
method
alloc
Stable since 1.54.0
Version 1.100.0-nightly
doc.rust-lang.org
pub fn split_inclusive<F>(&self, pred: F) -> SplitInclusive<'_, T, F>
slice::split_inclusive — Returns an iterator over subslices separated by elements that match pred. The matched element is contained in the end of the previous subslice as a terminator.
Examples
let slice = [10, 40, 33, 20];
let mut iter = slice.split_inclusive(|num| num % 3 == 0);
assert_eq!(iter.next...
method
core
Stable since 1.51.0
Version 1.100.0-nightly
doc.rust-lang.org
pub const fn binary_search(&self, x: &T) -> Result<usize, usize>
...If the value is found then Result::Ok is returned, containing the index of the matching element. If there are multiple matches, then any one of the matches could be returned. The index is chosen deterministically, but is subject to change in future versions of Rust. If the value is...
method
core
Stable since 1.0.0
Version 1.100.0-nightly
doc.rust-lang.org
pub enum ErrorKind
...This list is intended to grow over time and it is not recommended to exhaustively match against it.
It is used with the io::Error type.
Handling errors and matching on ErrorKind
In application code, use match for the ErrorKind values you are expecting; use _ to match "all other errors...
enum
core
Stable since 1.0.0
Version 1.100.0-nightly
github.com
...a `match` statement takes one expression and applies multiple patterns to it until one matches,
while let-else-else-chains would take one pattern and apply it to multiple expressions until one matches.
This has a complexity issue with or-patterns, where expressions can _easily_ become exponential.
(This is already...
RFC 3137
RFC
2021-05-31
~21 min read
doc.rust-lang.org
...match PrintOnDrop("Matched value in final expression") {
// Non-pattern-matching guards' temporaries are dropped once the
// condition has been evaluated
_ if PrintOnDrop("guard condition").0 == "" => (),
// Pattern-matching guards' temporaries are dropped when leaving the
// arm's scope
_ if let "guard scrutinee" = PrintOnDrop("guard scrutinee").0 => {
let _ = &PrintOnDrop("lifetime-extended temporary...
The Rust Reference
Book
2024-01-01
~16 min read
doc.rust-lang.org
pub fn rsplit<F>(&self, pred: F) -> RSplit<'_, T, F>
slice::rsplit — Returns an iterator over subslices separated by elements that match pred, starting at the end of the slice and working backwards. The matched element is not contained in the subslices.
Examples
let slice = [11, 22, 33, 0, 44, 55];
let mut iter = slice.rsplit(|num| *num == 0);
assert...
method
core
Stable since 1.27.0
Version 1.100.0-nightly
doc.rust-lang.org
pub fn split_inclusive<P>(&self, pat: P) -> SplitInclusive<'_, P>
str::split_inclusive — Returns an iterator over substrings of this string slice, separated by characters matched by a pattern.
Differs from the iterator produced by split in that split_inclusive leaves the matched part as the terminator of the substring.
The pattern can be a &str, char, a slice of...
method
core
Stable since 1.51.0
Version 1.100.0-nightly
doc.rust-lang.org
pub fn binary_search_by_key<'a, B, F>(&'a self, b: &B, f: F) -> Result<usize, usize>
...If the value is found then Result::Ok is returned, containing the index of the matching element. If there are multiple matches, then any one of the matches could be returned. If the value is not found then Result::Err is returned, containing the index where a matching element could...
method
alloc
Stable since 1.54.0
Version 1.100.0-nightly
doc.rust-lang.org
pub const fn binary_search_by<'a, F>(&'a self, f: F) -> Result<usize, usize>
...If the value is found then Result::Ok is returned, containing the index of the matching element. If there are multiple matches, then any one of the matches could be returned. The index is chosen deterministically, but is subject to change in future versions of Rust. If the value is...
method
core
Stable since 1.0.0
Version 1.100.0-nightly
rust-lang.github.io
Summary
Change syntax of subslices matching from ..xs to xs.. to be more consistent with the rest of the language and allow future backwards compatible improvements.
Small example:
match slice {
[xs.., _] => xs,
[] => fail!()
}
This is basically heavily stripped version of RFC 101.
Motivation
In Rust, symbol after .. token usually describes...
RFC 202
RFC
2014-08-15
~1 min read
doc.rust-lang.org
pub const fn binary_search_by_key<'a, B, F>(&'a self, b: &B, f: F) -> Result<usize, usize>
...If the value is found then Result::Ok is returned, containing the index of the matching element. If there are multiple matches, then any one of the matches could be returned. The index is chosen deterministically, but is subject to change in future versions of Rust. If the value is...
method
core
Stable since 1.10.0
Version 1.100.0-nightly
doc.rust-lang.org
pub fn split_mut<F>(&mut self, pred: F) -> SplitMut<'_, T, F>
slice::split_mut — Returns an iterator over mutable subslices separated by elements that match pred. The matched element is not contained in the subslices.
Examples
let mut v = [10, 40, 30, 20, 60, 50];
for group in v.split_mut(|num| *num % 3 == 0) {
group[0] = 1;
}
assert_eq!(v...
method
core
Stable since 1.0.0
Version 1.100.0-nightly
doc.rust-lang.org
pub struct SplitInclusive<'a, P>
SplitInclusive — An iterator over the substrings of a string, terminated by a substring matching to a predicate function Unlike Split, it contains the matched part as a terminator of the subslice.
This struct is created by the split_inclusive method on str. See its documentation for more.
struct
core
Stable since 1.51.0
Version 1.100.0-nightly
dannas.name
...fn match_here(regex: &[u8], text: &[u8]) -> bool {
match (regex, text) {
(&[], _) => true,
(&[b'$'], &[]) => true,
(&[b'$'], _) => false,
(&[r, b'*', ref rs @ ..], txt) => {
match_star(r, rs, txt)
}
(&[_, ref _s @ ..], &[]) => false,
(&[r, ref rs @ ..], &[t, ref ts @ ..]) if r == b'.' || r == t => {
match_here(rs, ts)
}
_ => false,
}
}
Finally we have the matching...
Rust Walkthroughs
2022-09-14
~7 min read