doc.rust-lang.org
...Code that looked like this:
// Rust 2015
extern crate futures;
use futures::Future;
mod foo {
pub struct Bar;
}
use foo::Bar;
fn my_poll() -> futures::Poll { ... }
enum SomeEnum {
V1(usize),
V2(String),
}
fn func() {
let five = std::sync::Arc::new(5);
use SomeEnum::*;
match ... {
V1(i) => { ... }
V2(s) => { ... }
}
}
will look...
The Rust Edition Guide
Book
2024-01-01
~7 min read
gekkio.fi
...let op = read_op();
match op {
// ...
0xC1 => { // POP BC
cpu.bc = mem_read_u16(cpu.sp);
cpu.sp += 2;
cpu.cycles += 3;
},
0xC5 => { // PUSH BC
cpu.sp -= 2;
mem_write_u16(cpu.sp, cpu.bc);
cpu.cycles += 4;
}
// ...
}
This might seem perfectly fine, but is actually inaccurate if we look...
Blog Posts
2015-01-19
~4 min read
rust-lang-nursery.github.io
...of an array in parallel | [![rayon-badge]][rayon] | [![cat-concurrency-badge]][cat-concurrency] | | Test in parallel if any or all elements of a collection match a given predicate | [![rayon-badge]][rayon] | [![cat-concurrency-badge]][cat-concurrency] | | Search items using given predicate in parallel | [![rayon-badge]][rayon] | [![cat-concurrency-badge]][cat...
The Rust Cookbook
Book
2024-01-01
~1 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
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
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
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
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
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
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
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
rust-lang.github.io
...when a target modifier changes), and that match the user's profile.
These proposals are drafts and are intended only to signpost future direction for this feature, and ensure compatibility with the current proposal:
• build-std.when = "compatible"
• build-std.when = "match-profile"
↩ Why does "always" rebuild in release profile...
RFC 3874
RFC
2025-06-05
~48 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.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
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
chillfish8.ghost.io
...The issue is we can't match relevant documents correctly when the two systems act in different ways.Act 2: Correcting the correction behaviourThe first plan of attack was simple -> just correct the index data itself and search that then return the original text separately. Simple right?Well yes and...
Observations/Thoughts
2021-11-24
~12 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