paulbutler.org
...We can match it to any value, and we can’t get the value back. Another place we see this is destructuring tuples where we only care about some of the values:
fn main() {
let my_tuple = (4, "foo", false);
let (num, _, truthy) = my_tuple;
println!("{} {}", num, truthy);
}
You often...
Rust Walkthroughs
2022-02-23
~8 min read
github.com
...However, once you've decided on the type you want to use, the compiler's normal type checks can guide you everywhere else in the code.
## Drawbacks
[drawbacks]: #drawbacks
* The compiler has less flexibility with respect to discriminant computation and pattern matching optimizations when a type is niche-optimized.
## Rationale...
RFC 3391
RFC
2023-04-18
~3 min read
digitalnk.com
...The first character I tried, ", was a match but nothing else matched. And in any case the table generated is way too small to handle Korean and Chinese characters. The decompiled pseudo-C code does not seem to depart from the assembly source either. I can’t quite explain all...
News & Blog Posts
2020-05-12
~48 min read
smallcultfollowing.com
...u32) -> Pin<Box<impl Future<Output = u32>>> {
Box::pin(async move {
match a {
0 => 1,
1 => 2,
_ => fibonacci(a-1).await + fibonacci(a-2).await
}
})
}
But wouldn’t it be nice if we could request this directly?box async fn fibonacci(a: u32) -> u32 {
match a {
0 => 1,
1 => 2...
Observations/Thoughts
2025-03-26
~21 min read
not-matthias.github.io
...Pretty easy, right?#[macro_export]
macro_rules! kernel_dbg {
() => {
$crate::println!("[{}:{}]", file!(), line!());
};
($val:expr) => {
// Use of `match` here is intentional because it affects the lifetimes
// of temporaries - https://stackoverflow.com/a/48732525/1063961
match $val {
tmp => {
$crate::println!("[{}:{}] {} = {:#?}",
file!(), line!(), stringify!($val), &tmp);
tmp
}
}
};
// Trailing comma with single argument...
Learn More Rust
2020-08-26
~12 min read
www.superperfundo.dev
...Let’s look at the implementation of intersect in sections.
// Hardcoded unit sphere
let sphere_center = Tuple::point(0.0, 0.0, 0.0);
// Transform the ray instead of the sphere - let the sphere stay at unit
let transform_inverse = match sphere.transform.inverse() {
Some(transform_inverse) => transform_inverse,
None...
Rust Walkthroughs
2023-04-12
~12 min read
gfx-rs.github.io
...We removed the old Vulkan-like model, but also upgraded the new model to match “VK_KHR_imageless_framebuffer”, getting the best of both worlds. It maps to the backends even better than before, and we can expose it directly in gfx-portability now.
There is also a lot of...
Project/Tooling Updates
2021-02-03
~3 min read
gitlab.com
...let mut vec = Vec::new();
vec.push(true);
vec.push(false);
vec.push(true);
vec.push(false);
vec.push(false);
vec.push(false);
vec.iter().cycle().for_each(|v| {
match v {
true => row.set_high().expect("Failed to set row high"),
false => row.set_low().expect("Failed to set row...
Rust Walkthroughs
2023-03-29
~7 min read
tonbo.io
...This matches how serverless systems actually work.
Tonbo makes concurrent reads and writes predictable on shared storage
Object storage does not provide database style coordination by default. To make concurrent reads and writes predictable, we built fusio-manifest on top of conditional PUTs in object storage, urning critical metadata updates...
Project/Tooling Updates
2024-08-14
~3 min read
github.com
...F) -> Option<T> {
let mut foo = unsafe {
mem::uninitialized::<T>()
};
let mut foo_ref = &mut foo as *mut T;
match std::panic::catch_unwind(|| {
let val = f();
unsafe {
ptr::write(foo_ref, val);
}
}) {
Ok(()) => Some(foo);
Err(_) => None
}
}
```
Naively, this code might look safe. The problem though is that by...
RFC 1892
RFC
2017-02-09
~8 min read
aaron404.github.io
...The counts for each digit are:Digit01234567Count40523861I slapped this into a match statement and boom! Optical character recognition!// Map the discriminant values to the digits they represent
fn count_to_digit(count: usize) -> Result<u8> {
Ok(match count {
4 => 0u8,
0 => 1,
5 => 2,
2 => 3,
3 => 4,
8 => 5...
Rust Walkthroughs
2024-07-31
~26 min read
www.meilisearch.com
...At indexing time — Create a text embedding based on title and description as text, and create an image embedding based on the image URL
At search time — Allow matching text based on a text query and image based on an inlined image
The payload below allows updating embedder settings accordingly...
Project/Tooling Updates
2025-08-06
~3 min read
dygalo.dev
...Vec<&str>) -> ValidationResult {
match (self, instance) {
// ... Compare `instance` type with expected type
_ => Err(ValidationError::new(
format!("{instance} is not of type '{self}'"),
// Convert path to an iterator
path.into_iter(),
)),
}
}
}
The ValidationError struct now stores this path:
struct ValidationError {
message: String,
/// Error location within the input instance.
location: Vec<String...
Observations/Thoughts
2024-05-15
~17 min read
rustc-dev-guide.rust-lang.org
...It is a bug if the index of a Param does not match what the EarlyBinder binds. For example, if the index is out of bounds or the index of a lifetime corresponds to a type parameter. These sorts of errors are caught earlier in the compiler during name resolution...
Guide to Rustc Development
Book
2024-01-01
~3 min read
alphakhaw.com
...make everything match the longest sample in the batch and move on.
It works, but part of every step is now spent processing tokens that do not contribute anything. NVIDIA’s NeMo docs put the waste at 50–70% of computation on padding tokens for skewed length distributions.NVIDIA NeMo...
Project/Tooling Updates
2026-04-01
~7 min read
r2cn.dev
...users describe the desired state of their workloads in YAML manifests, and Kubernetes continuously reconciles the actual cluster state to match it.
Strengths: This model is highly reliable in production, offering features such as rolling updates, automatic restarts, resource limits, and sophisticated scheduling across nodes. It’s ideal for large...
Observations/Thoughts
2025-08-20
~12 min read
blog.kuviman.com
...Err),
}
#[derive(Debug, Copy, Clone)]
pub struct Percent(u8);
impl FromStr for Percent {
type Err = ParsePercentError;
fn from_str(s: &str) -> Result<Self, ParsePercentError> {
match s.parse() {
Ok(value) if value <= 100 => Ok(Percent(value)),
Ok(_) => Err(ParsePercentError::TooBig),
Err(e) => Err(ParsePercentError::ParseIntError(e)),
}
}
}
- dialoguer & indicatif
Sometimes you need...
News & Blog Posts
2018-07-24
~3 min read
lib.rs
...use osmpbf::{ElementReader, Element};
let reader = ElementReader::from_path("tests/test.osm.pbf")?;
// Count the ways
let ways = reader.par_map_reduce(
|element| {
match element {
Element::Way(_) => 1,
_ => 0,
}
},
|| 0_u64, // Zero is the identity value for addition
|a, b| a + b // Sum the partial results
)?;
println!("Number of ways...
Crate of the Week
2022-06-08
~3 min read
deislabs.io
...Our Mission
At its core, Kubernetes relies on declarative (mostly immutable) manifests, and
controllers which run reconciliation loops to drive cluster state to match this
configuration. Kubelet is no exception to this, with its focus being
indivisible units of work, or Pods. Kubelet simply monitors for changes to Pods
that...
Learn More Rust
2020-09-30
~17 min read
doc.rust-lang.org
...When we use the get method with the index passed as an argument, we get an Option<&T> that we can use with match.
Rust provides these two ways to reference an element so that you can choose how the program behaves when you try to use an index value...
The Rust Programming Language
Book
2024-02-01
~8 min read