steveklabnik.com
...the profit from the book won’t go to me, it will go to OpenHatch, “a non-profit dedicated to matching prospective free software contributors with communities, tools, and education,” to use their words about it.
I’ll let you know when we’re closer to actually shipping!
News & Blog Posts
2015-09-14
~1 min read
blog.lilyf.org
...swapped_context
};
let cloned = py_context.clone();
let content = self.func.call1(
py, (cloned,)?;
let inner_context = match
Arc::try_unwrap(
py_context.context) {
Ok(inner_context) => {
inner_context
}
Err(_) => todo!(),
};
let _ = std::mem::replace(
context, inner_context);
Ok(content.to_string())
}
}
}
This works great when Python doesn’t keep...
Rust Walkthroughs
2025-09-03
~5 min read
blog.japaric.io
...a task token whose type must match the
interrupt field of the declaration, a priority token whose type must match
the priority field of the declaration, and a threshold token whose type must
match the level of the priority token.
The priority and threshold tokens we have already seen. The...
News & Blog Posts
2017-05-09
~37 min read
219design.com
...Example
match block!(bnrg.with_spi(&mut spi, |c| c.read())) {
Ok(p) => {
let hci::host::uart::Packet::Event(e) = p;
match e {
bluetooth_hci::event::Event::ConnectionComplete(params) => {
// handle the new connection
}
bluetooth_hci::event::Event::Vendor(
bluenrg::event::BlueNRGEvent::HalInitialized(reason),
) => {
// handle the BlueNRG chip reset
}
_ => (),
}
}
Err(e...
News & Blog Posts
2018-10-09
~12 min read
trifectatech.org
...allow unaligned reads in longest_match
wasm: SIMD adler32
wasm: SIMD slide_hash
wasm: use wider loads/stores in copy_match
wasm: SIMD compare256
Decompression
implementationspeedup (wall time)
baseline-41.1%
miniz-oxide-54.9%
zlib-ng-25.3%
Our optimizations made our implementation over 40% faster; we're now...
Observations/Thoughts
2024-11-20
~3 min read
noyez.gitlab.io
...Deserializer<'de>
{
match MacOrU64::deserialize(deserializer)? {
MacOrU64::U64(v) => { Ok(v) }
MacOrU64::Mac(v) => {
mac_addr_as_u64(&v).ok_or(serde::de::Error::custom("Can't parse MAC address"))
}
}
}
Note the #[serde(untagged)] attribute which makes the serialized JSON an anonymous object. See the serde documentation for serge’s...
News & Blog Posts
2018-09-04
~3 min read
arxiv.org
...These guarantees come from a strong ownership-based type system, as well as primitive support for features like closures, pattern matching, etc., that make the code more concise and amenable to reasoning. These unique Rust features also pose a steep learning curve for programmers.
This paper presents a tool called...
Research
2023-08-23
~1 min read
nadrieril.github.io
...let tmp = x.method();
something(&tmp.field);
This is exactly what we need for postfix macros: <expr>.macro!() would become (using a match to
make the temporary lifetimes work as they should 🤞):
match <expr> {
place p => macro!(p),
}
This would have the effect I propose above: any side-effects...
Observations/Thoughts
2025-12-10
~8 min read
rust.code-maven.com
...For example by using match and handling the Ok and Err cases separately.
Inside the prompt function we don't have any explicit error handling. We just added ? at the end of the calls that might fail.
This means if either of those calls fail, the prompt function immediately returns...
Miscellaneous
2024-01-03
~3 min read
jaredonline.svbtle.com
...fn update(&mut self, maps: &mut Maps, windows: &mut Windows) {
match Game::get_last_keypress() {
Some(ks) => {
match ks.key {
// Because Shift is used for attack keys we don't want to do
// anything when it's pushed. We can check for shift when we
// process the next keypress
SpecialKey...
Blog Posts
2014-11-24
~19 min read
rust-dd.com
...This allows the router to match incoming request paths and extract the values of dynamic segments at runtime. For instance, a pattern like /users/{id} is turned into a regex that matches /users/123 (or any other value in place of {id}) and captures the id value.
By default, route...
Project/Tooling Updates
2025-07-23
~16 min read
blog.sheerluck.dev
...impl Card for PokerCard {
fn value(&self) -> u8 {
match self.rank {
Rank::Two => 2,
Rank::Three => 3,
// ...
Rank::Ace => 11,
}
}
fn is_face(&self) -> bool {
// custom override
matches!(self.rank, Rank::Jack | Rank::Queen | Rank::King)
}
}Trait Bounds
Remember the max function that would not compile? Traits fix it.
fn...
Rust Walkthroughs
2026-05-13
~17 min read
doc.rust-lang.org
...missing fragment specifier
}
fn main() {
foo!();
}
Calling the macro with arguments that would match a rule with a missing specifier (e.g., foo!($name)) was a hard error in all editions. However, simply defining a macro with missing fragment specifiers was not, though we did add a lint in Rust...
The Rust Edition Guide
Book
2024-01-01
~1 min read
blog.shortepic.com
...enum NextPlayerChange {
Start,
Next,
}
impl Mutator<SquareMark> for NextPlayerChange {
fn mutate(&self, v: &SquareMark) -> SquareMark {
use SquareMark::*;
match self {
Self::Start => X,
Self::Next => match v {
X => O,
O => X,
Empty => unreachable!(),
},
}
}
}
A square is state, indexable within the board. We set up some defaults so they start Empty, but...
Learn More Rust
2020-10-07
~8 min read
lucumr.pocoo.org
...impl Value {
fn as_str(&self) -> Option<&str> {
match self {
Value::String(s) => Some(s),
_ => None,
}
}
fn to_string(&self) -> String {
match self {
Value::String(s) => s.clone(),
Value::Number(n) => n.to_string(),
}
}
}
So far, so good. What’s important about this particular piece of code we just wrote...
Observations/Thoughts
2022-09-14
~16 min read
deislabs.io
...But most powerfully, we see the use of a match statement when we try to patch the
status with the API. This match lets us handle the result and unwrap the data inside, performing a
different branch of logic based on the result.
Now let’s look at the same...
News & Blog Posts
2020-04-14
~8 min read
apanatshka.github.io
...Benchmarks not matching either
prefix are ignored completely.
If benchmark output is sent on stdin, then the second version is used and the
third file parameter is not needed.
Options:
-h, --help Show this help message and exit.
--version Show the version.
--threshold <n> Show only comparisons with a percentage...
News & Blog Posts
2016-09-06
~8 min read
immunant.com
...Each va_start
and va_copy call must be matched by exactly one va_end call in the same
function.
For example, this is a very common implementation of the printf function:
int printf(const char *fmt, ...) {
int res;
va_list ap;
va_start(ap, fmt);
res = vprintf(fmt, ap...
News & Blog Posts
2019-09-17
~8 min read
www.sea-ql.org
...common-async-runtime/async_std_task.rs/// A shim to match tokio's APIpub struct TaskHandle<T>(async_std::task::JoinHandle<T>);pub fn spawn_task<F, T>(future: F) -> TaskHandle<T>where F: Future<Output = T> + Send + 'static, T: Send + 'static,{ TaskHandle(async_std::task::spawn(future))}#[derive(Debug...
Observations/Thoughts
2023-11-22
~3 min read
thatgeoguy.ca
...Matching enums
By default Rust has built in support for deconstruction / pattern-matching enum
types (even ones you define!). From our earlier example we can do:
let x: PixelFormat; // Assume this is given a value from something
match x {
PixelFormat::Yuv{ y, u, v } => {
println!("Pixel is y: {}, u: {}, v...
Rust Walkthroughs
2021-02-17
~8 min read