udoprog.github.io
...Decoder>(d: &mut D) -> Result<path::PathBuf, D::Error> { .. }
| }
| }
}
It works by detecting when your platform has a configuration which does not match any existing gates, providing you with contextual information of why it failed. This means that the matching would either have to be exhaustive (e.g. provide a...
News & Blog Posts
2018-02-20
~10 min read
immunant.com
...libc::c_int = 0;
match ::core::mem::size_of::<libc::c_int>() as libc::c_ulong {
1 => asm!("movb %gs:$1,$0" :
"=q" (pfo_ret__) :
"*m" (&cpu_number)
: : "volatile"),
2 => asm!("movw %gs:$1,$0" :
"=r" (pfo_ret__) :
"*m" (&cpu_number)
: : "volatile"),
4 => asm!("movl %gs:$1,$0" :
"=r" (pfo...
News & Blog Posts
2020-07-08
~6 min read
mo8it.com
...In Rust, you should do proper pattern matching:
let mut v = vec![1.0];
let v1 = match v.pop() {
Some(value) => value,
None => 1.0,
};
let v2 = match v.pop() {
Some(value) => value,
None => 1.0,
};
v1 * v2
We use pattern matching to handle the Option.
In case the Option...
Observations/Thoughts
2023-07-19
~27 min read
aibodh.com
...You declare what you need, Bevy queries the world and returns every match.
fn track_hit_player(
mut players: Query<&mut Health>,
enemies: Query<&Transform>,
) {
dodge(&enemies);
shoot(&enemies, &mut players);
}
Chapter 1 — Let There Be a Player
Trigger chain reactions across systems
Fire one event and Bevy broadcasts it...
Observations/Thoughts
2026-05-27
~2 min read
kerkour.com
...Blob(
Uuid::now_v7().as_bytes().to_vec(),
)))
}
fn uuid<'a>(ctx: &Context<'_>) -> Result<ToSqlOutput<'a>, rusqlite::Error> {
let arg = ctx.get_raw(0);
match arg {
rusqlite::types::ValueRef::Text(text) => {
// if it's TEXT: convert it to BLOB
let uuid = Uuid::try_parse_ascii(text)
.map_err(|err| rusqlite...
Rust Walkthroughs
2025-10-15
~5 min read
www.tweag.io
...The following is a
direct conversion of a good chunk of mysql.yaml into Nickel syntax, omitting
uninteresting values:
{
apiVersion = "v1",
kind = "Pod",
metadata = {
name = "mysql",
labels.name = "mysql",
},
spec = {
containers = [
{
resources = {
image = "mysql",
name = "mysql",
ports = [
{
containerPort = 3306,
name = "mysql",
}
],
volumeMounts = [
{
# name must match the volume name below
name...
Project/Tooling Updates
2023-06-14
~11 min read
arzg.github.io
...GreenNodeBuilder::new(),
events,
}
}
pub(super) fn finish(mut self) -> GreenNode {
for event in self.events {
match event {
Event::StartNode { kind } => {
self.builder.start_node(EldiroLanguage::kind_to_raw(kind))
}
Event::StartNodeAt { kind, checkpoint } => self
.builder
.start_node_at(Checkpoint(checkpoint), EldiroLanguage::kind_to_raw(kind)),
Event::AddToken { kind, text } => {
self...
Rust Walkthroughs
2020-12-09
~14 min read
doc.rust-lang.org
...boolean, numeric, char, and str
• Generic type parameters
• Self type
• Tool attribute modules
• Value Namespace
• Function declarations
• Constant item declarations
• Static item declarations
• Struct constructors
• Enum variant constructors
• Self constructors
• Generic const parameters
• Associated const declarations
• Associated function declarations
• Local bindings --- let, if let, while let, for, match arms, function...
The Rust Reference
Book
2024-01-01
~3 min read
willcrichton.net
...For example, Rust uses macros for simple pattern-matching-based code substitution (a more powerful and hygienic version of the C preprocessor), e.g. to implement variadic arguments like in println! and early returns like in try!.
fn main() {
println!("{} {} {}", "This has", "many", "arguments");
}
However, pattern-matching-based metaprogramming tools...
News & Blog Posts
2018-03-20
~11 min read
willcrichton.net
...For example, Rust uses macros for simple pattern-matching-based code substitution (a more powerful and hygienic version of the C preprocessor), e.g. to implement variadic arguments like in println! and early returns like in try!.
fn main() {
println!("{} {} {}", "This has", "many", "arguments");
}
However, pattern-matching-based metaprogramming tools...
Learn More Rust
2020-09-04
~11 min read
blog.yoshuawuyts.com
...The select! {} macro introduces a custom DSL which resembles match blocks,
but with a few twists. Unlike a match block which takes a single input,
select! {} takes multiple futures, creates named bindings to them when they
resolve, and executes a block when it executes. It also has a complete case...
Rust Walkthroughs
2022-02-16
~36 min read
redox-os.org
...Redoxfs wasn’t matching Posix for permissions handing on file creation and unlink. There was a small bug in getcwd, and a kernel issue with dup2 as well as cloexec handling. For some reason the default SHA1 implementation in git wasn’t working; I’m not sure why, but overriding...
News & Blog Posts
2017-07-25
~2 min read
guillaumegomez.github.io
...E0529
Other contributions:
@JDemler fixed typo in nomicon.
@fanzier fixed typo in PartialOrd docs.
@johnthagen updated nightly docs supported Windows versions to match Getting Started page.
@Sawyer47 removed incorrect methods inherited through Deref by filtering them.
@tshepang fixed doc coercion.
@frewsxcv indicated where core::result::IntoIter is created and added...
New Crates & Project Updates
2016-09-13
~2 min read
turbopuffer.com
...In fact, our query planner
reported the size of the relevant filter bitmaps (representing which documents
match each filter value) as only 67MB for this query. Based on some
napkin math, reading from an NVMe SSD
(at a max throughput of 6,240 MB/s) and processing should only take...
Observations/Thoughts
2026-03-04
~12 min read
andreabergia.com
...call_stack, instruction);
match instruction_result {
Ok(ReturnFromMethod(return_value)) => return Ok(return_value),
Ok(ContinueMethodExecution) => { /* continue the loop */ }
Err(MethodCallFailed::InternalError(err)) => {
return Err(MethodCallFailed::InternalError(err))
}
Err(MethodCallFailed::ExceptionThrown(exception)) => {
let exception_handler = self.find_exception_handler(
vm,
call_stack,
executed_instruction_pc,
&exception,
);
match exception_handler {
Err...
Observations/Thoughts
2023-07-19
~11 min read
sdr-podcast.com
...And to not have weird like loop match statements where you're like doing manual state machine changes. And someone even in the in the Rust subreddit today posted something where they're like, can I do this? And they posted some loop match. And I'm like, if you...
Observations/Thoughts
2025-06-18
~39 min read
doc.rust-lang.org
...self.ptr = match NonNull::new(new_ptr as *mut T) {
Some(p) => p,
None => alloc::handle_alloc_error(new_layout),
};
self.cap = new_cap;
}
}
impl<T> Drop for RawVec<T> {
fn drop(&mut self) {
if self.cap != 0 {
let layout = Layout::array::<T>(self.cap).unwrap();
unsafe {
alloc::dealloc(self...
The Rustonomicon
Book
2024-01-01
~2 min read
doc.rust-lang.org
...macro_rules! lexes {($($_:tt)*) => {}}
lexes!{a #foo}
lexes!{continue 'foo}
lexes!{match "..." {}}
lexes!{r#let#foo} // three tokens: r#let # foo
lexes!{'prefix #lt}
Examples accepted before the 2021 edition but rejected later:
macro_rules! lexes {($($_:tt)*) => {}}
lexes!{a#foo}
lexes!{continue'foo}
lexes!{match"..." {}}
lexes!{'prefix#lt}
Reserved guards...
The Rust Reference
Book
2024-01-01
~20 min read
rustc-dev-guide.rust-lang.org
...Introduced in RFC 3425. (see more) rustbuild 👎 | A deprecated term for the part of bootstrap that is written in Rust scrutinee | A scrutinee is the expression that is matched on in match expressions and similar pattern matching constructs. For example, in match x { A => 1, B => 2 }, the expression x...
Guide to Rustc Development
Book
2024-01-01
~15 min read
www.jaredwolff.com
...TelemetryData = match serde_cbor::from_slice(&data) {
Ok(t) => t,
Err(e) => {
// Create error
let error = TelemetryError {
error: "Unable to parse telemetry data.".to_string(),
};
// Return error
return warp::reply::json(&error);
}
};
This uses the from_slice function which turns raw bytes into something useful. I’m using a match...
Rust Walkthroughs
2020-11-25
~13 min read