app.codecrafters.io
...for stream in listener.incoming() {
match stream {
Ok(stream) => {
// handle the connection
}
Err(e) => {
eprintln!("Failed: {}", e);
}
}
}
The TcpStream struct
The iterator returned from TcpListener::incoming yields instances of TcpStream.
Some important methods associated with the TcpStream struct are:
impl TcpStream {
// read reads bytes from the stream
pub fn read...
Miscellaneous
2024-04-24
~3 min read
bheisler.github.io
...On the other
hand, adding or renaming an ingredient could cause the fuzzy-matching to pick a totally different
closest-match than what it did when I wrote the recipe to start with, which I don’t want.
Every ingredient and recipe (and anything else I add to the system...
Rust Walkthroughs
2020-11-25
~12 min read
doc.rust-lang.org
...Scrutinee
A scrutinee is the expression that is matched on in match expressions and similar pattern matching constructs. For example, in match x { A => 1, B => 2 }, the expression x is the scrutinee.
Size
The size of a value has two definitions.
The first is that it is how much...
The Rust Reference
Book
2024-01-01
~9 min read
determinate.systems
...impl Instrumentation { // (continued) pub(crate) fn setup(&self) -> color_eyre::Result<()> { let filter_layer = self.filter_layer()?; let registry = tracing_subscriber::registry() .with(filter_layer) .with(tracing_error::ErrorLayer::default()); // `try_init` called inside `match` since `with` changes the type match self.logger { Logger::Compact => { registry.with(self.fmt_layer...
Rust Walkthroughs
2023-08-09
~14 min read
blog.veeso.dev
...Indeed the amount of frames in the backtrace can be huge (especially when using tokio), and we want to find the last frame that matches one of the modules we are interested in.
So we'll have to provide a list of modules to the allocator, and it will use...
Observations/Thoughts
2025-07-02
~8 min read
erickt.github.io
...State) -> (Option<usize>, State) {
loop {
state = match state {
State::Enter => {
return_!(Some(0); State::AfterYield0);
}
State::AfterYield0 => {
return_!(Some(1); State::AfterYield1);
}
State::AfterYield1 => {
return_!(Some(2); State::AfterYield2);
}
State::AfterYield2 => {
goto!(State::Exit);
}
State::Exit => {
return_!(None; State::Exit);
}
}
}
}
}
We move the current state into advance, then have this...
News & Blog Posts
2016-02-01
~6 min read
www.fluvio.io
...use fluvio_smartstream::{smartstream, Record};#[smartstream(filter)]pub fn filter_odd(record: &Record) -> bool { // Parse the input bytes as a UTF-8 string, or return false let string_result = std::str::from_utf8(record.value.as_ref()); let string = match string_result { Ok(s) => s, _ => return false, }; // Parse the string...
Project/Tooling Updates
2021-08-04
~6 min read
write.yiransheng.com
...In cases where multiple peers match, the one with the
longest prefix match is selected.
Conversely, for incoming UDP datagrams, after decapsulation, we
obtain an IP packet with a known source address (src).
Given the connected Peer from which this packet originates,
we check if src falls within that peer...
Rust Walkthroughs
2023-12-20
~58 min read
fasterthanli.me
...But also… we need to pattern match again.
Like so:
match (&this.a, &this.b) {
(State::Ok(_), State::Ok(_)) => {
let a = match std::mem::replace(&mut this.a, State::Gone) {
State::Ok(t) => t,
_ => unreachable!(),
};
let b = match std::mem::replace(&mut this.b, State::Gone) {
State::Ok(t...
Rust Walkthroughs
2021-07-28
~70 min read
www.newrustacean.com
...chriskrycho
Twitter: @chriskrycho
A dummy container for use with references.A simple example of using the dereference operator.A simple demonstration of matching against a reference type.Give a basic example of how the reference operator works.
News & Blog Posts
2016-08-09
~1 min read
trifectatech.org
...Currently rustc cannot generate this instruction, but we plan to add it as an extension of #[loop_match], a feature that I worked on in a previous Project Goal. I wrote about this earlier in Improving state machine code generation . Currently #[loop_match] is only useful when the next state...
Observations/Thoughts
2026-04-15
~12 min read
llogiq.github.io
...² Java’s switch statement is both less powerful than the fully destructuring
pattern matching of Rust’s match and has surprising fallthrough between
case statements (I have my IDE warn on this to mitigate the surprise).
Note that this list is incomplete, and some things don’t completely match...
News & Blog Posts
2016-02-29
~26 min read
blog.meilisearch.com
...It was related to the fact that Meilisearch did not have enough data to rate crates except the query matching words.
Meilisearch doesn't know how to settle equal crates with only the matching words
Downloads counts amazingly improved the search results. This data is available through crates.io. A...
News & Blog Posts
2019-11-12
~4 min read
github.com
...The innermost expression that encloses both of these
expressions is the match itself (as depicted above), and hence the
borrow is considered to extend until the end of the
match. Unfortunately, the match encloses not only the `Some` branch,
but also the `None` branch, and hence when we go to...
RFC 2094
RFC
2017-08-02
~67 min read
arxiv.org
...On the NVIDIA B200 GPU, cuTile Rust achieves 7 TB/s for element-wise operations and 2 PFlop/s for GEMM (96% of cuBLAS), matching cuTile Python within measurement noise. Grout, a cuTile-Rust-based inference engine, exercises cuTile Rust across an end-to-end Qwen3 inference path. In batch...
Project/Tooling Updates
2026-06-17
~1 min read
blog.adamperry.me
...A super nifty part of the stackcollapse scripts for flamegraph is that they let you grep for functions matching a pattern. Protip: all Rust benchmark harnesses invoke a closure like so: bencher.iter(|| do_measured_thing()), easily allowing you to grep for calls to closures to limit the flamegraph to...
News & Blog Posts
2016-07-26
~20 min read
blog.cloudflare.com
...Env) -> Result<Response> {
console_log!(
"{} {}, located at: {:?}, within: {}",
req.method().to_string(),
req.path(),
req.cf().coordinates().unwrap_or_default(),
req.cf().region().unwrap_or("unknown region".into())
);
if !matches!(req.method(), Method::Post) {
return Response::error("Method Not Allowed", 405);
}
if let Some(file) = req.form_data().await?.get...
Miscellaneous
2021-09-15
~3 min read
matklad.github.io
...impl<T> Drop for Node<T> {
fn drop(&mut self) {
loop {
match (self.left.take(), self.right.take()) {
(None, None) => break,
(None, Some(it)) | (Some(it), None) => *self = *it,
(Some(left), Some(right)) => {
*self =
*if left.depth > right.depth { left } else { right }
}
}
}
}
}
This requires maintaining the depths though. Can we...
Observations/Thoughts
2022-11-23
~4 min read
ryanskinner.com
...This is what happens when your architecture matches React's design intentions.The Three Missing PiecesLooking back, I realize we'd shipped Rari with some architectural gaps. Not bugs—gaps. We could render React Server Components, but we weren't doing it the right way. Here's what we added...
Project/Tooling Updates
2025-10-29
~6 min read
rolisz.ro
...use core::fmt;
use crate::map::State::{Gray, Red, Blue, Black};
impl fmt::Display for State {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
let char = match self {
Gray => 'N',
Red => 'R',
Blue => 'B',
Black => 'X'
};
write!(f, "{}", char)
}
}
impl fmt::Display for Cell<'_> {
fn fmt(&self, f: &mut...
News & Blog Posts
2020-06-16
~12 min read