javierviola.com
...PlayerId = req.query().unwrap_or_default();
let state = req.state().clone();
let petnames = Petnames::default();
let player_id = match client.id {
Some( id ) => id,
None => petnames.generate_one(2, ".")
};
let player = Player {
id : PlayerId {id : Some(player_id.clone())},
wsc : wsc.clone(),
label: String::from("")
};
match state.add_player_to...
Rust Walkthroughs
2021-02-03
~11 min read
blog.darklang.com
...both OCaml and Rust are effectively using a pointer to another Expr.But what happens when we get to pattern matching? Well, here's how we do it in OCaml (full version here):(function
| state, [DList l; DBlock b] ->
let f (dv : dval) : dval = Ast.execute_dblock ~state b [dv...
Observations/Thoughts
2020-08-26
~15 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
treit.github.io
...let opt = s.get(1..1000);
match opt {
Some(slice) => println!("{} - {}", s, slice),
None => println!("Did not produce a slice!"),
}
}
This illustrates two possible ways (if let and match) of pattern matching on an Option result and extracting the result, if any.
Declarative coding fun with iterators
We have examined...
News & Blog Posts
2020-03-17
~12 min read
jdrouet.github.io
...If we insert Alice, then searching alice won't find it, it's only exact match. This is good for matching email addresses, folder names, etc. The text index, on the opposite, the input data gets processed, but we'll talk about it right after.Once again, we can follow...
Rust Walkthroughs
2025-04-02
~18 min read
github.com
...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-part-four-draft]
- [`build-std.when = "match-profile"`][build-std...
RFC 3874
RFC
2025-06-05
~50 min read
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
dhruv-ahuja.github.io
...Operation) {
let is_empty = queue.len() == 0;
let is_full = queue.len() == self.capacity;
match operation {
Operation::Push { mut is_full_flag } => {
let mut is_empty_flag = self.is_empty.lock().unwrap();
if *is_empty_flag {
*is_empty_flag = false;
println!("set is_empty to false");
self.is_empty_signal...
Rust Walkthroughs
2023-09-06
~9 min read
greptime.com
...ident) => {
paste! {
fn [<eval_ $O>](columns: &[VectorRef]) -> Result<VectorRef> {
with_match_primitive_type_id!(columns[0].data_type().logical_type_id(), |$S| {
with_match_primitive_type_id!(columns[1].data_type().logical_type_id(), |$T| {
with_match_primitive_type_id!(columns[2].data_type().logical_type_id(), |$R| {
// clip(a...
Rust Walkthroughs
2025-11-26
~14 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
v5.0.1
2026-06-26
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
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
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
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
www.ncameron.org
...changelog
Atom IDE v0.11 - tag
RFCs
2285 - Update the disambiguation handling in RFC 1946 (intra-rustdoc-links) to match impl concerns - FCP merge
2287 - Benchmarking / cargo bench - FCP close - superseded by 2318
2318 - Post Build Contexts (custom test frameworks)
Meetings
Find all meeting notes here, some highlights:
Cargo build...
News & Blog Posts
2018-02-06
~1 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
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
www.nymi.com
...At Nymi, everyone has a passion for making the future better than today and the courage to blaze that path. Our Culture is Recognized for Enabling Employees to Do Their Best WorkHybrid work options to match your styleWe've got a dynamic, open-concept office in the heart of Toronto...
Rust Jobs
2021-08-18
~1 min read
berline.rs
...In this event we will finish Rust’s Patterns and Matching!
Rust is a language empowering everyone to build reliable and efficient software.
Let’s meet for open hacking and (co)-learning in our bi-weekly learning group!
Everyone is welcome. Rusties of all skill levels meet and hack on...
Virtual
2022-06-15
~1 min read
github.com
...i32 = 3.pow(3);
match x {
CUBE => println!("three cubed"),
_ => {}
}
}
```
If that `const` is only used inside a single pattern, writing the code using an
inline `const` block makes it easier to scan.
```rust
fn foo(x: i32) {
match x {
const { 3.pow(3) } => println!("three cubed"),
_ => {}
}
}
```
## Reference-level explanation...
RFC 2920
RFC
2020-04-30
~7 min read