audunhalland.github.io
...This meant that it wasn't possible to use the matching!-macro on that parameter.
The matching macro operates on immutable views of the function inputs, where a single, common lifetime parameter cuts it (because matching only reads things and does not return anything).
Given these limitations it became clear...
Project/Tooling Updates
2024-03-27
~3 min read
willspeak.me
...loop {
let mut state = Start;
let mut end = start;
for c in source[start..].chars() {
let next = match state {
Start => match c {
'(' => Some(Lparen),
')' => Some(Rparen),
'0'...'9' => Some(Number),
'a'...'z' => Some(Symbol),
c if c.is_whitespace() => Some(Whitespace),
_ => None,
},
Lparen | Rparen => None,
Number => match c {
'0'...'9...
News & Blog Posts
2019-07-16
~10 min read
rust-analyzer.github.io
#5821 Remove Unused Parameter refactoring.
#5695 completion for unstable features.
#5643 Add new consuming modifier to semantic syntax highlighting, apply consuming and mutable to methods.
#5758 structural search replace now inserts *, & and &mut in the
replacement to match any auto[de]ref in the matched code.
#5682 allow disabling specific...
Tooling
2020-08-26
~1 min read
radekmie.dev
...At its core, the Matcher class does the heavy lifting and handles all the querying logic, i.e., checking whether a document matches a query.In JavaScript, it’s implemented as a cascade of nested closures, i.e., functions take some information about the query and return a function that...
Observations/Thoughts
2025-07-23
~7 min read
doc.rust-lang.org
...Values that are matched with wildcards must still be initialized.
let x: u8;
let c = || {
let _ = x; // ERROR: Binding `x` isn't initialized.
};
Capturing for discriminant reads
If pattern matching reads a discriminant, the place containing that discriminant is captured by ImmBorrow.
Matching against a variant of an enum that...
The Rust Reference
Book
2024-01-01
~20 min read
github.com
## Summary
[summary]: #summary
Currently when using an if let statement and an irrefutable pattern (read always match) is used the compiler complains with an `E0162: irrefutable if-let pattern`.
The current state breaks macros who want to accept patterns generically and this RFC proposes changing this error to an error...
RFC 2086
RFC
2017-07-27
~2 min read
github.com
## Summary
Add a `literal` fragment specifier for `macro_rules!` patterns that matches literal constants:
```rust
macro_rules! foo {
($l:literal) => ( /* ... */ );
};
```
## Motivation
There are a lot of macros out there that take literal constants as arguments (often string constants). For now, most use the `expr` fragment specifier, which is fine since...
RFC 1576
RFC
2016-04-08
~3 min read
andreabergia.com
...Just as it should be. 😊
Finding the exception handler
Link to heading
Finding a matching exception handler is just a question of checking all of them, in order, and stopping with the first one that matches, i.e. whose catch class is a superclass of the actual exception class, since...
Miscellaneous
2023-09-27
~9 min read
nnethercote.github.io
...impl ::core::cmp::Ord for Point {
#[inline]
fn cmp(&self, other: &Point) -> ::core::cmp::Ordering {
- match *other {
- Self {
- x: ref __self_1_0,
- y: ref __self_1_1,
- } => match *self {
- Self {
- x: ref __self_0_0,
- y: ref __self_0_1,
- } => match ::core::cmp::Ord::cmp(&(*__self_0_0), &(*__self...
Observations/Thoughts
2022-07-20
~16 min read
github.com
...Finally, it is useful for the reader to keep in mind that according to
the definitions of this RFC, no simple NT matches
the empty fragment, and likewise no token matches
the empty fragment of Rust syntax. (Thus, the *only* NT that can match
the empty fragment is a complex...
RFC 550
RFC
2014-12-21
~21 min read
dtrace.org
...For that we’ll use matching, another handy construct.
23 let mut v: Vec<char> = s.chars().collect();
24 v.sort();
25 let ss: String = v.into_iter().collect();
26
27 match dict.get(&ss) {
28 Some(mut v) => v.push(s),
29 _ => {
30 let mut v = Vec::new();
31...
Tips & Tricks
2015-06-29
~12 min read
blog.burntsushi.net
...PCRE2 match error: match limit exceeded
Aborted (core dumped)
The Silver Searcher fails similarly. It reports the first line as a match and
neglects the match in the third line. The rest of the search tools benchmarked
in this article handle this case without a problem.
Literal optimizations
Picking a...
News & Blog Posts
2016-09-27
~92 min read
github.com
## Summary
[summary]: #summary
Add a `lifetime` specifier for `macro_rules!` patterns, that matches any valid
lifetime.
## Motivation
[motivation]: #motivation
Certain classes of macros are completely impossible without the ability to pass
lifetimes. Specifically, anything that wants to implement a trait from inside of
a macro is going to need to...
RFC 1590
RFC
2016-04-22
~1 min read
lucumr.pocoo.org
...impl error::Error for LibError {
fn description(&self) -> &str {
match *self {
BadStatusCode => "bad status code",
IoError(err) => "encountered an I/O error",
}
}
fn detail(&self) -> Option<String> {
match *self {
BadStatusCode(code) => Some(format!("status code was {}", code)),
_ => None,
}
}
fn cause(&self) -> Option<&error::Error> {
match *self {
IoError(ref err) => Some...
Blog Posts
2014-11-10
~12 min read
github.com
...Each of the features has
a distinct motivation, and we should evaluate them independently.
## Unresolved questions
These questions should be satisfactorily resolved before stabilizing the
relevant features, at the latest.
### Optional `match` sugar
Originally, the RFC included the ability to `match` the errors caught
by a `catch` by writing `catch...
RFC 243
RFC
2014-09-16
~20 min read
rust-lang.github.io
...For instance, the following is an erroneous use of the match keyword:
fn match(needle: &str, haystack: &str) -> bool {
haystack.contains(needle)
}
error: expected identifier, found keyword `match`
--> src/lib.rs:1:4
|
1 | fn match(needle: &str, haystack: &str) -> bool {
| ^^^^^
It can instead be written as fn r#match...
Updates from Rust Core
2018-03-27
~4 min read
www.ferrisfencing.org
...The Rules
Matches are contested between two fencers, each named Ferris, and each
running in their own VM.
The fencers square off on a one-dimensional grid 10 spaces wide.
Each match consists of 5 games. The player to win the most games wins the match.
Games consist of up...
News & Blog Posts
2019-10-29
~1 min read
hackeryarn.com
...Matching multi-field select
#[macro_export]
macro_rules! query {
( from $db:ident select $( $field:ident ),+ ) => {
...
};
}
That's quite a bit of new syntax, but it all breaks down to a single new matching construct.
Repetition match syntax
The general shape for matching repetition looks like:
$ ( ... ) sep rep => {
...
$ ( ... ) rep
...
}
We need...
Rust Walkthroughs
2025-09-03
~6 min read
blog.servo.org
...Selector matching has been extracted into an independent library! You can see it here.
We now have automation set up for our Gonk (Firefox OS) port, and gate on it.
Notable additions
Chris Paris landed fragment parsing in html5ever
and implemented the innerHTML setter in Servo.
Jack Moffitt added a...
Project Updates
2015-03-02
~1 min read
lifthrasiir.github.io
...MyTrait;
// @matches foo/trait.Bravo.html '//pre' "Bravo.*where.*B:.*MyTrait"
pub trait Bravo<B> where B: MyTrait {}
// @matches foo/fn.charlie.html '//pre' "charlie.*where.*C:.*MyTrait"
pub fn charlie<C>() where C: MyTrait {}
pub struct Delta<D>;
// @matches foo/struct.Delta.html '//*[@class="impl"]//code' "impl.*Delta.*where...
Blog Posts
2015-01-19
~2 min read