smallcultfollowing.com
...This operator desugars into a pattern match, but it has the effect of “propagating” the error to the caller of the function. If we look at the copy_data one more time, but imagine that any potential errors were propagated using results, it would look like:fn copy_data(from...
Observations/Thoughts
2022-02-02
~6 min read
hoverbear.org
...std::time::Duration::new(0, 0) }
}
}
fn to_filling(&mut self) {
self.state = match self.state {
State::Waiting { .. } => State::Filling { rate: 1 },
_ => panic!("Invalid state transition!"),
}
}
}
fn main() {
let mut state_machine = StateMachine::new();
state_machine.to_filling();
}
At first glance it seems okay. But notice some problems?
Invalid transition...
Blog Posts
2016-10-18
~18 min read
hoverbear.org
...std::time::Duration::new(0, 0) }
}
}
fn to_filling(&mut self) {
self.state = match self.state {
State::Waiting { .. } => State::Filling { rate: 1 },
_ => panic!("Invalid state transition!"),
}
}
}
fn main() {
let mut state_machine = StateMachine::new();
state_machine.to_filling();
}
At first glance it seems okay. But notice some problems?
Invalid transition...
Rust Walkthroughs
2025-04-16
~18 min read
www.fpcomplete.com
...Couldn't match type 'IO Int' with 'Int'
Expected type: [Int]
Actual type: [IO Int]
Instead, we need to use map's more powerful cousin, traverse (a.k.a. mapM, or "monadic map"). traverse allows us to perform a series of actions, and produce a new list with all of...
Miscellaneous
2020-10-14
~12 min read
arxiv.org
...On the NVIDIA B200 GPU, cuTile Rust achieves 7 TB/s for element-wise operations and 2 PFlop/s for GEMM (96% of cuBLAS), matching cuTile Python within measurement noise. Grout, a cuTile-Rust-based inference engine, exercises cuTile Rust across an end-to-end Qwen3 inference path. In batch...
Project/Tooling Updates
2026-06-17
~1 min read
blogsystem5.substack.com
...c_uint,
}It is very important to declare the structure as having a C representation so that its memory layout matches what the C compiler produces for the same structure. The kernel expects C semantics in its system call boundary, and we must adhere to that. Additionally, we must ensure...
Rust Walkthroughs
2025-02-19
~14 min read
rustc-dev-guide.rust-lang.org
...These can then be mapped to DefIds using TyCtxt::get_diagnostic_item() or checked if they match a DefId using TyCtxt::is_diagnostic_item(). When mapping from a diagnostic item to a DefId, the method will return a Option<DefId>. This can be None if either the symbol isn't...
Guide to Rustc Development
Book
2024-01-01
~4 min read
docs.rs
...Attribute::remove_attributes which takes an &mut Vec<syn::Attribute> and does not only parse the Attribute but also removes those matching. Useful for helper attributes for proc macros, where the helper attributes need to be removed. For parsing a single TokenStream e.g. for parsing the proc macro input...
Crate
v0.11.0
2026-09-12
crates.io
...As such, substrings may not always match your intuition: use substring::Substring; assert_eq!("ã".substring(0, 1), "a"); // As opposed to "ã". assert_eq!("ã".substring(1, 2), "\u{0303}") The above example occurs because "ã" is technically made up of two UTF-8 scalar values: the letter "a...
Crate
v1.4.5
2021-02-04
docs.rs
Macros to keep types in lockstep with DBus XML definitions zbus-lockstep-macros zbus-lockstep-macros extends zbus-lockstep to match the signature of signal types <T as zvariant::Type>::signature() with a corresponding signature from a DBus XML file more conveniently and succinctly. Motivation In the context of IPC...
Crate
v0.8.0
2026-11-16
docs.rs
...1u64 }).unwrap(); ident.normalize().unwrap(); assert!(matches!(ident, Format::TypeName(s) if s.ends_with("Foo<u64>"))); Contributing See the CONTRIBUTING file for how to help out. License This project is available under the terms of either the Apache 2.0 license or the MIT license .
Crate
v0.3.0
2026-05-26
www.lpalmieri.com
...web::Data<PgPool>,
) -> HttpResponse {
let name = match SubscriberName::parse(form.0.name) {
Ok(name) => name,
// Return early if the name is invalid, with a 400
Err(_) => return HttpResponse::BadRequest().finish(),
};
let new_subscriber = NewSubscriber {
email: form.0.email,
name,
};
match insert_subscriber(&pool, &new_subscriber).await {
Ok(_) => HttpResponse::Ok().finish...
Rust Walkthroughs
2020-12-16
~31 min read
docs.rs
...I run async every 7 seconds"); // Query the next execution time for this job let next_tick = l.next_tick_for_job(uuid).await; match next_tick { Ok(Some(ts)) => println!("Next time for 7s job is {:?}", ts), _ => println!("Could not get next tick for 7s job"), } }) })? ).await?; // Needs the...
Crate
v0.15.1
2025-10-28
arXiv
arxiv.org
...For other topics (e.g., related topics with language features such as structs, patterns and matchings, and foreign function interface), information is only available on Q&A websites while lacking in the official documentation. Finally, we discuss implications for programming language documenters, particularly how to leverage our approach to prioritize...
Software Engineering
Filipe R. Cogo, Xin Xia, Ahmed E. Hassan
2022-02-08
arXiv:2202.04431
blog.digital-horror.com
...Vec<String> = domains.into_iter().map(|x| x.to_owned()).collect();
match mode {
EnrichmentMode::DnsLookup => {
// Ignore for now
}
EnrichmentMode::MxCheck => {
// Ignore for now
}
_ => return Err("enrichment mode not yet implemented"),
}
Ok(domain_store)
}https://github.com/JuxhinDB/twistrs/blob/ddc6facfeae818ea15a523d9a1e9fb04ce3e61fd/src/lib.rs#L601-L632The more astute reader might also...
Learn More Rust
2020-09-09
~14 min read
doc.rust-lang.org
...i32,
}
impl FromStr for Circle {
type Err = ParseIntError;
fn from_str(s: &str) -> Result<Self, Self::Err> {
match s.trim().parse() {
Ok(num) => Ok(Circle{ radius: num }),
Err(e) => Err(e),
}
}
}
fn main() {
let radius = " 3 ";
let circle: Circle = radius.parse().unwrap();
println!("{:?}", circle);
}
Rust by Example
Book
2024-01-01
~1 min read
doc.rust-lang.org
pub fn get_key_value<Q>(&self, k: &Q) -> Option<(&K, &V)>
...The supplied key may be any borrowed form of the map's key type, but the ordering on the borrowed form must match the ordering on the key type.
Examples
use std::cmp::Ordering;
use std::collections::BTreeMap;
#[derive(Clone, Copy, Debug)]
struct S {
id: u32,
name: &'static str, // ignored...
method
alloc
Stable since 1.40.0
Version 1.100.0-nightly
arXiv
arxiv.org
Normal Distributions Transform (NDT) scan matching has strongly input-dependent execution time on the localization critical path. We study the align kernel of Autoware's production matcher; map loading, preprocessing, and Robot Operating System scheduling are outside the timed scope. Our three-layer method enforces and property-tests a conditional...
Distributed Computing
Yuuki Takano
2026-08-06
arXiv:2611.33159
rustc-dev-guide.rust-lang.org
...fn foo() {}
fn bar() {}
let a = match my_bool {
true => foo,
true if other_bool => foo,
false => bar,
}
In this example when type checking the match expression a LUB coercion is performed. This LUB coercion starts out with an initial lub ty of some inference variable ?x due to the...
Guide to Rustc Development
Book
2024-01-01
~12 min read
blog.arnedebo.com
...bind_slice! can be used to store a borrowed reference of whatever was matched inside into a bucket.
Parsing function signatures
#
We will now move to a slightly larger example, parsing a function signature grammar looking like this:
IDENT = 'a'..'z', { 'a'..'z' | '0'..'9' } ;
FN_SIGNATURE = 'fn', WHITESPACE, IDENT...
Rust Walkthroughs
2026-06-03
~9 min read