vitiral.github.io
...Many of the concepts that rust taught such as
expressions returning a value
and pattern matching
were utilized for exactly the same benefit in elm.
A frontend in elm with a backend in rust is a match made in heaven: fun,
performant and safe.
Rust web development
Before I got...
News & Blog Posts
2016-12-13
~4 min read
ohadravid.github.io
...snip ..
}
}
Again, the matching code from dav1d doesn’t initialize this buffer.
Here, switching to MaybeUninit is more difficult, but we can still offer a modest improvement: we’ll only need to do the initialization once if we hoist lr_bak to the top level!pub(crate) fn rav1d_cdef...
Observations/Thoughts
2025-05-28
~14 min read
17:28
New Rustacean
newrustacean.com
Episode: e021: Keeping your types under cover
...Destructuring assignment uses the same kind of syntax as pattern matching, but it does it outside the body of a match expression. It lets you bind directly to any public member in the interior of a struct or enum variant. You should note, though, that you can't do this...
Podcast
2017-07-18
17:28
dev.to
...Using Result for Error Handling
use std::fs::File;
use std::io::ErrorKind;
fn main() {
let greeting_file_result = File::open("hello.txt");
let greeting_file = match greeting_file_result {
Ok(file) => file,
Err(error) => match error.kind() {
ErrorKind::NotFound => match File::create("hello.txt") {
Ok(fc) => fc,
Err(e...
Observations/Thoughts
2026-02-04
~9 min read
docs.rs
...TokenStream) -> Result<TokenStream> { // Parse the struct or enum you want to implement a derive for let parse = Parse::new(input)?; // Get a reference to the generator let (mut generator, body) = parse.into_generator(); match body { Body::Struct(body) => { // Implement your struct body here // See `Generator` for more information generator.impl...
Crate
v0.0.19
2025-12-17
andreabergia.com
...Pair<'_, Rule>) -> Block {
rule.into_inner()
.map(|statement| match statement.as_rule() {
Rule::letStatement => parse_statement_let(statement),
Rule::assignmentStatement => parse_statement_assignment(statement),
Rule::returnStatement => parse_statement_return(statement),
Rule::block => BlockElement::NestedBlock(parse_block(statement)),
_ => unreachable!(),
})
.collect()
}
As you can see, it maps pretty closely the grammar’s...
Rust Walkthroughs
2025-02-19
~13 min read
rust-lang.github.io
...The app code looks something like:
// search for "#define FOO nnn"
fn find_c_defines(input: &str) {
let rx = Regex::new(r#"^#define\s+(\w+)\s+([0-9]+)\s*(//(.*))?"#).unwrap();
for captures in rx.captures_iter(input) {
let my_match: Match = captures.get(1).unwrap();
do_some_work(my_match...
RFC 3191
RFC
2021-11-01
~21 min read
fitzgeraldnick.com
...When I benchmark my change against SpiderMonkey, I don’t see any
significant performance improvement from matching the arity.
Next, mraleph noticed that the generic sorting routine was not being
monomorphized, and the comparator functions passed to it were not being inlined.
To mold the JavaScript code into something that...
News & Blog Posts
2018-02-27
~10 min read
codspeed.io
...u64) -> u64 { match n { 0 => 1, 1 => 1, n => fibonacci(n-1) + fibonacci(n-2), } } pub fn criterion_benchmark(c: &mut Criterion) { c.bench_function("fib 20", |b| b.iter(|| fibonacci(black_box(20)))); } criterion_group!(benches, criterion_benchmark); criterion_main!(benches); The last step in creating the Criterion benchmark...
Crate
v6.1.0
2026-11-20
ricardomartins.cc
...A better way to convert the enum variants to the correct values is an explicit match:
impl From<PacketType> for u8 {
fn from(original: PacketType) -> u8 {
match original {
PacketType::Data => 0,
PacketType::Fin => 1,
PacketType::State => 2,
PacketType::Reset => 3,
PacketType::Syn => 4,
}
}
}
Pretty straightforward, right? Since the mapping from...
News & Blog Posts
2016-08-09
~15 min read
www.ncameron.org
...macro_rules macros in Rust and syntax-rules macros in Scheme allow for pattern matching of arguments in the macro definition, so different code is substituted for the macro use depending on the arguments.
Depending on how macros are defined will affect how and when macros are lexed and parsed...
News & Blog Posts
2015-10-12
~4 min read
laurmaedje.github.io
...Some pattern include dots to indicate that the
pattern should only match at the start or end of the word.
Now, to find out how to hyphenate a word, we first need a
zero-initialized array of levels with length one less than that of the
word (one entry for...
Observations/Thoughts
2022-07-27
~10 min read
tweedegolf.nl
...We can then configure pin P0_12 as a pullup with sense input like so:let p0_register_block = nrf52840_hal::pac::P0::ptr();
unsafe { &(*p0_register_block).pin_cnf[12] }.write(|w| {
w.dir().input();
w.input().connect();
w.pull().pullup();
w.drive().s0s1();
match sense_when_goes_to...
Rust Walkthroughs
2021-06-09
~6 min read
doc.rust-lang.org
...pointer is directly expected, but also when different function item types with the same signature meet in different arms of the same if or match:
# let want_i32 = false;
# fn foo<T>() { }
// `foo_ptr_1` has function pointer type `fn()` here
let foo_ptr_1: fn() = foo::<i32>;
// ... and so...
The Rust Reference
Book
2024-01-01
~1 min read
rust-lang.github.io
...fn deserialize_from(dest: &mut MyBigEnum) -> Result<(), Error> {
let tag = deserialize_tag()?;
match tag {
A => {
let payload = deserialize_a()?
*dest = A(payload);
}
..
}
Ok(())
}
We must construct the entire payload out-of-place, and then move it into place at the end, even though our API is specifically designed to let...
RFC 2195
RFC
2017-10-30
~13 min read
trifectatech.org
...We believe we can justify this regression though, because with the unsafe-performance-experimental feature flag enabled we match C performance. This feature flag disables 4 bounds checks where data from the input is used to index into a data structure. For most users a ~3% performance regression is likely...
Project/Tooling Updates
2026-06-03
~4 min read
boats.gitlab.io
...This also matches the best default for what we believe will be the primary use
case for alternative registries: internal registries for private organizations.
Rather than requiring each new project to redeclare its dependency on that
registry, each machine can be preconfigured to be able to locate the registry.
Pulling...
News & Blog Posts
2017-10-31
~7 min read
docs.rs
...Wrap the mutable Broccoli FFI entry points in a local catch_unwind helper, matching the encoder FFI convention so Rust panics do not unwind across extern C when std panic catching is available. Return BrotliFileNotCraftedForConcatenation on caught panics and keep the existing pass-through behavior for no-std or pass...
Crate
v9.1.3
2026-11-15
blog.vashishtha.in
...fasterthanlime's "A Rust match made in hell" explores a similar problem related to how match expression scrutinees can extend temporary lifetimes, and how that conflicts with locks.
The section discussing current rules in Niko Matsaki's similarly titled "Temporary Lifetimes"
I'm looking for Summer 2025 internships. Feel free...
Rust Walkthroughs
2023-01-25
~4 min read
wishawa.github.io
...The polling code can then match the returned enum and perform the branching.
Shared mutable borrows#
We also let async blocks share mutable borrows as long as they don't cross any await yieldpoint. This is done by parsing through all the blocks to find shared borrows, and putting all...
Rust Walkthroughs
2023-04-19
~4 min read