christian.amsuess.com
...W) -> Result<(), W::Error> {
let chunk = self.data.view(request_data.block);
match chunk {
Ok((payload, option)) => {
message.set_code(code::Content);
message.add_opaque_option(option::ETag, &self.etag)?;
message.add_block_option(option::Block2, option);
message.add_payload(payload)?;
}
Err(_) => {
message.set_code(code::BadRequest);
}
};
Ok(())
}
As these...
Call for Blog Posts
2020-09-30
~5 min read
www.evanmiller.org
...Like if, match is an expression, not a statement, so it can be used as an rvalue. But unlike if, match doesn’t suffer from the phantom-else problem. The compiler uses type-checking to guarantee that the match will match something — or speaking more precisely, the compiler will complain...
Notable Links
2015-05-18
~35 min read
stace.dev
...if let Some(answer) = get_answer(&response) {
match answer {
DnsRecord {
data: DnsRecordData::Ipv4Addr(ip),
type_: TYPE_A,
..
} => return Ok(*ip),
DnsRecord {
data: DnsRecordData::Name(name),
type_: TYPE_CNAME,
..
} => return resolve(name, TYPE_A),
_ => {
panic!("resolve: something went wrong")
}
}
}
Using match to destructure the data enum based on a DNS record...
Observations/Thoughts
2023-07-19
~5 min read
docs.rs
...by default. .stdout(stdout) // Redirect stdout to `/tmp/daemon.out`. .stderr(stderr) // Redirect stderr to `/tmp/daemon.err`. .privileged_action(|| "Executed before drop privileges"); match daemonize.start() { Ok(_) => println!("Success, daemonized"), Err(e) => eprintln!("Error, {}", e), } } License Licensed under either of Apache License, Version 2.0 ( LICENSE-APACHE or http...
Crate
v0.5.0
2023-02-25
blog.viraptor.info
...It
doesn’t support regex matching or casting parameters to the right type, but
it’s functional. Same goes for logging and static file handling. No thrills,
they work.
There aren’t that many template libraries to choose from yet, but
handlebars-iron does the job.
The feeling that when...
Notable Links
2015-06-07
~7 min read
14:12
New Rustacean
newrustacean.com
Episode: News: Rust 1.25
Paths and matches and SIMD, cargo new changes, and tons of community-driven learning materials! Show Notes Rust 1.25.0 blog post RFC #1358 – #[repr(align)] RFC #2325 – SIMD stabilization RustConf CFP Hello Rust “Functional and Concurrent Programming in Rust” Sponsors Aaron Turon Alexander Payne Anthony Deschamps Anthony Scotti...
Podcast
2018-03-31
14:12
rust-lang-nursery.github.io
...The path! macro is used to define what URL matches. The :query is a template — it matches anything and stores the value as query for the component to read later.
<A> anchors links while <Routes fallback=...> is used to provide a default.
More in the Leptos book: Defining <Routes/> and...
The Rust Cookbook
Book
2024-01-01
~3 min read
docs.rs
...In those cases you should use a version of xmltree that matches the version of xml you are using: xml version xmltree version 1 0.12 0.8 0.11 0.7 0.8 0.6 0.6 Example See the documentation for some examples: https://docs.rs/xmltree/
Crate
v0.12.0
2025-11-10
mtigley.dev
...action_status is an immutable referencee to the player object’s associated ActionStatus component, which we will use to match on its action_type property:match action_status.action_type {
Action::Idle => {
sprite.sprite_number = animation.first_sprite_index + frame as usize;
},
Action::Run => {
// The first running animation is the...
Learn More Rust
2020-08-26
~7 min read
docs.rs
...use tokio::time::{Duration, sleep}; #[tokio::main] async fn main() { let (tx, mut rx) = bmrng::channel_with_timeout::<i32, i32>(100, Duration::from_millis(100)); tokio::spawn(async move { match rx.recv().await { Ok((input, mut responder)) => { sleep(Duration::from_millis(200)).await; let res = responder.respond(input * input); assert...
Crate
v0.5.2
2021-08-24
crates.io
...std")] { let (response_sender, response_receiver) = oneshot::channel(); let request = Request::from("data from sync thread"); processor.send((request, response_sender)).expect("Processor down"); match response_receiver.recv_timeout(Duration::from_secs(1)) { // <- Receive on the oneshot channel Ok(result) => println!("Processor returned {}", result), Err(oneshot::RecvTimeoutError::Timeout) => eprintln!("Processor...
Crate
v0.2.1
2026-02-23
flodl.dev
...Recurrent — full sequence modules, not just cells:
// Multi-layer GRU matching nn.GRU exactly
let gru = GRU::new(128, 256, 2)?; // 2 layers
let (output, h_n) = gru.forward_seq(&x, None)?;
// Multi-layer LSTM matching nn.LSTM
let lstm = LSTM::new(128, 256, 2)?;
let (output, (h_n, c...
Project/Tooling Updates
2026-04-01
~5 min read
rust-lang-nursery.github.io
...badge]][csv] | [![cat-encoding-badge]][cat-encoding] | | Read CSV records with different delimiter | [![csv-badge]][csv] | [![cat-encoding-badge]][cat-encoding] | | Filter CSV records matching a predicate | [![csv-badge]][csv] | [![cat-encoding-badge]][cat-encoding] | | Handle invalid CSV data with Serde | [![csv-badge]][csv] [![serde-badge]][serde] | [![cat-encoding-badge...
The Rust Cookbook
Book
2024-01-01
~1 min read
rust-lang.github.io
...High-level summary:
• several unnecessary uses of repr(packed) (patches have been submitted and merged to remove all of these)
• most necessary ones are to match the declaration of a struct in C
• many "necessary" uses can be replaced by byte arrays/arrays of smaller types
• 8 crates are currently...
RFC 1240
RFC
2015-08-06
~10 min read
minikin.me
...TrafficLightEvent) -> TrafficLightState {
match (self, event) {
// Normal cycle
(TrafficLightState::Red, TrafficLightEvent::Timer) => TrafficLightState::Green,
(TrafficLightState::Green, TrafficLightEvent::Timer) => TrafficLightState::Yellow,
(TrafficLightState::Yellow, TrafficLightEvent::Timer) => TrafficLightState::Red,
// Emergency override
(_, TrafficLightEvent::Emergency) => TrafficLightState::Red,
}
}
}
// Usage
fn main() {
let mut state = TrafficLightState::Red;
println!("Initial state: {:?}", state);
// Normal cycle
state = state.next(TrafficLightEvent::Timer...
Rust Walkthroughs
2025-03-19
~22 min read
arzg.github.io
...Let’s add an is_trivia method to SyntaxKind to abstract away this behaviour:impl SyntaxKind {
pub(crate) fn is_trivia(self) -> bool {
matches!(self, Self::Whitespace | Self::Comment)
}
}
Note how the method takes self; this is because it’s more efficient to pass SyntaxKind by value instead of by...
Rust Walkthroughs
2020-12-16
~3 min read
github.com
...This matches the behavior of brotli with a custom dictionary as specified in https://datatracker.ietf.org/doc/draft-vandevenne-shared-brotli-format/ What's new in version 4.0.3 Better handling of corrupt brotli files. What's new in version 4.0.2 Better handling of corrupt brotli...
Crate
v6.4.0
2026-11-24
docs.rs
...find_executable_in_path is the most convenient function exported by this crate; given the name of an executable, it will yield the absolute path of the first matching file. use pathsearch::find_executable_in_path; if let Some(exe) = find_executable_in_path("ls") { println!("Found ls at {}", exe...
Crate
v0.2.0
2020-04-11
doc.rust-lang.org
pub const UNIX_EPOCH: SystemTime
...Examples
use std::time::{SystemTime, UNIX_EPOCH};
match SystemTime::now().duration_since(UNIX_EPOCH) {
Ok(n) => println!("1970-01-01 00:00:00 UTC was {} seconds ago!", n.as_secs()),
Err(_) => panic!("SystemTime before UNIX EPOCH!"),
}
constant
std
Stable since 1.8.0
Version 1.100.0-nightly
kerkour.com
...errs::Error) -> HttpResponse {
let (status, code) = match &err {
Error::AuthenticationRequired => (StatusCode::UNAUTHORIZED, "UNAUTHORIZED"), // 401
Error::PermissionDenied(_) => (StatusCode::FORBIDDEN, "FORBIDDEN"), // 403
Error::NotFound(_) => (StatusCode::NOT_FOUND, "NOT_FOUND"), // 404
_ => (StatusCode::INTERNAL_SERVER_ERROR, "INTERNAL_SERVER_ERROR"), // 500
};
let message = match &self {
err @ Error::Internal(_) => {
// log the internal error
error!("{err}");
err...
Observations/Thoughts
2026-05-20
~8 min read