siciarz.net
...Time for our first request!
extern crate hyper;
use hyper::Url;
use hyper::client::Request;
fn main() {
let url = match Url::parse("http://httpbin.org/status/200") {
Ok(url) => url,
Err(_) => panic!("Uh oh."),
};
println!("> get: {}", url);
let fresh_request = match Request::get(url) {
Ok(request) => request,
Err(_) => panic!("Whoops...
Blog Posts
2014-12-08
~4 min read
blog.sheerluck.dev
...Vec<(usize, String)> = Vec::new();
let mut line_number = 1;
for line in contents.lines() {
let is_match = regex.is_match(line);
let should_include = if invert { !is_match } else { is_match };
if should_include {
results.push((line_number, line.to_string()));
}
line_number += 1;
}
results
}
We are borrowing contents...
Rust Walkthroughs
2026-04-15
~15 min read
arzg.github.io
...u8) {
let checkpoint = p.checkpoint();
match p.peek() {
Some(SyntaxKind::Number) | Some(SyntaxKind::Ident) => p.bump(),
Some(SyntaxKind::Minus) => {
let op = PrefixOp::Neg;
let ((), right_binding_power) = op.binding_power();
}
_ => {}
}
loop {
let op = match p.peek() {
Some(SyntaxKind::Plus) => InfixOp::Add,
Some(SyntaxKind::Minus) => InfixOp::Sub,
Some(SyntaxKind::Star) => InfixOp...
Rust Walkthroughs
2020-11-18
~6 min read
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
arXiv
arxiv.org
...Using Qwen3-4B as the primary generator under matched token budgets, DTV improves pass rates from 72.3% to 82.0% on C-to-Rust and from 33.3% to 46.0% on JavaScript-to-TypeScript relative to matched self-refinement baselines, while using fewer tokens per case; the same...
Machine Learning
Tianyang Zhou, Somesh Jha, Mihai Christodorescu et al.
2026-05-17
arXiv:2605.17626
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
docs.rs
...TokenStream) -> TokenStream { let macro_string = parse_macro_input!(input as MacroString); let path = match macro_string.eval() { Ok(path) => path, Err(err) => return TokenStream::from(err.to_compile_error()), }; let content = match fs::read(&path) { Ok(content) => content, Err(err) => return TokenStream::from(macro_string.error(err).to_compile_error...
Crate
v0.3.0
2026-07-18
docs.rs
...let all_matched: String = selection.iter().map(|s| s.inner_html().trim().to_string()).collect(); assert_eq!( all_matched, "<li>1</li><li>2</li><li>3</li><li>4</li><li>5</li><li>6</li>" ); // or: let all_matched: String = selection.nodes().iter().map(|s| s.inner_html...
Crate
v0.28.0
2026-05-18
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