bluejekyll.github.io
...SocketAddr) -> io::Result<Socket> {
let ip_addr = addr.ip();
let socket = new_socket(&addr)?;
// depending on the IP protocol we have slightly different work
match ip_addr {
IpAddr::V4(ref mdns_v4) => {
// join to the multicast address, with all interfaces
socket.join_multicast_v4(mdns_v4, &Ipv4Addr::new(0, 0...
News & Blog Posts
2018-03-20
~19 min read
lucumr.pocoo.org
...Deserialize>(&self) -> ApiResult<T> {
Ok(serde_json::from_reader(match self.body {
Some(ref body) => body,
None => &b""[..],
})?)
}
One thing you can see here is that the body is buffered into memory
entirely. I was torn on this in the beginning but it actually turns out
to make the API...
News & Blog Posts
2016-07-12
~9 min read
seanmonstar.com
...An improved timeout option was added, read_timeout, which better matches how many want to detect a broken connection, instead of an entire request deadline.
HTTP/3 support returned, unstable but better, with IPv6 and content-length fixes.
Integration with rustls gained support for the new aws-lc backend, and...
Miscellaneous
2025-01-22
~4 min read
whoisryosuke.com
...Vec<f32> = Vec::new();
loop {
let packet = match format.next_packet() {
Ok(p) => p,
Err(symphonia::core::errors::Error::IoError(_)) => break,
Err(err) => {
eprintln!("Error decoding packet: {err}");
break;
},
};
if packet.track_id() != track_id {
continue;
}
let decoded = decoder.decode(&packet).expect("Couldn't decode audio");
match decoded {
AudioBufferRef::F32...
Rust Walkthroughs
2026-03-18
~60 min read
notes.iveselov.info
...error messageAnother very useful method in Rust is as_ref which converts from &Option<T> to Option<&T> which is very handy for pattern matching. as_mut plays a similar role for mutable references.In Rust there are several methods related to ownership of the value in the Option, like...
News & Blog Posts
2020-03-24
~4 min read
codesandbox.io
...The web IDE runs rust-analyzer for getting autocompletions, type information and language code actions like “turn if into match statement”.
Every sandbox also has a public URL that you can share with others. This way you can easily share your running Rust app with others. If you want to...
Miscellaneous
2023-01-25
~4 min read
blog.zortax.de
...The
compiler checks that the match is exhaustive, but it does not check the
arithmetic. The memo above has one definition, and a new writer cannot forget
it.
The same thing happens with location. Where does a hover state or a half-typed
draft live? Single source of truth says...
Observations/Thoughts
2026-11-11
~20 min read
matklad.github.io
...With a tree, you need to figure out
where to put the new crate, and, if there isn’t a perfect match for
it already, you’ll have to either:
add a stupid mostly empty folder near the top
add a catch-all utils folder
place the code in a...
Observations/Thoughts
2021-08-25
~4 min read
rust-osdev.com
...Fix risc target_arch cfg
Match MaximumCapsuleSize to UEFI spec
Add RuntimeServices::update_capsule
Add RuntimeServices::query_capsule_capabilities
Note about feature flags for uefi book
uefi-raw: misc
mem: clarify confusion around MemoryDescriptor
uefi/helpers: logger logs to debugcon device
Add basic API for a global system table
uefi...
Newsletters
2024-06-12
~3 min read
maplant.com
...Such a language is squarely in the design phase, but here’s a preview of what it might look
like:
(enum Option (Some 'a)
(None))
(let ([x (Some 5)])
(match x
((Some y) y)
((None) (random))))
(fn random () (-> 'a)
(where (: 'a Distribution))
(sample (thread-rng)))
(class Eq (self)
(: = (-> self self...
Observations/Thoughts
2025-02-19
~4 min read
syu-m-5151.hatenablog.com
...serde_json::Value,
) -> anyhow::Result<()> {
let name = params_val
.get("name")
.and_then(|v| v.as_str())
.unwrap_or("");
match name {
"list_terraform_resources" => {
self.handle_list_terraform_resources(transport, id).await?;
}
"analyze_terraform" => {
self.handle_analyze_terraform(transport, id, ¶ms_val).await?;
}
"get_terraform_plan" => {
self.handle_get_terraform...
Project/Tooling Updates
2025-03-12
~4 min read
robinmoussu.gitlab.io
...fn serialize(buffer: &mut Vec<u8>, tagged_union: &TaggedUnion) {
buffer.push(tagged_union.discriminant);
buffer.extend_from_slice(
match tagged_union.discriminant {
0 => { let data: &[u8; size_of::<[u8; 7]>()] = unsafe{transmute(&tagged_union.data)}; data },
1 => { let data: &[u8; size_of::<f32>()] = unsafe{transmute(&tagged_union.data)}; data },
2...
News & Blog Posts
2020-04-29
~15 min read
www.firezone.dev
...let address = parse_binding_response(packet);
self.state = State::Received { address };
}
fn poll_transmit(&mut self) -> Option<Transmit> {
self.buffered_transmits.pop_front()
}
fn public_address(&self) -> Option<SocketAddr> {
match self.state {
State::Sent => None,
State::Received { address } => Some(address),
}
}
}
The handle_input function is like the inverse to Transmit...
Observations/Thoughts
2024-07-03
~20 min read
corrode.dev
...fn is_root(file: &Path) -> bool {
matches!(fs::canonicalize(file), Ok(p) if p == Path::new("/"))
}
if recursive && preserve_root && is_root(file) {
return Err(PreserveRoot);
}Rule: Resolve Paths Before Comparing Them
canonicalize resolves .., ., and symlinks into a real absolute path. That’s a lot better than string comparison.
Oh...
Observations/Thoughts
2026-04-29
~14 min read
ferrous-systems.com
...We now exactly match the output of the bitflags crate.
1.3quicken flip-link build time vol. 2
You might remember our effort to improve the build time of flip-link: https://ferrous-systems.com/blog/knurling-changelog-28/#non-default-flip-link. This continues now!
Our goal is to...
Project/Tooling Updates
2021-09-01
~4 min read
marcos.unsafe.rs
...O(1)
fn naive_search(haystack: &str, needle: &str) -> bool {
let [haystack, needle] =
[haystack, needle].map(str::as_bytes);
haystack
.windows(needle.len())
.any(|haystack_window| haystack_window == needle)
}
For each window (with the needle size) in the haystack, check if it matches the needle.
I want this, but vroom...
Observations/Thoughts
2023-10-25
~9 min read
mbuffett.com
...We’ll also be tackling system ordering in this
section, since we’ve neglected it so far.The first thing we need to add is a direction enum:#[derive(PartialEq, Copy, Clone)]
enum Direction {
Left,
Up,
Right,
Down,
}
impl Direction {
fn opposite(self) -> Self {
match self {
Self::Left => Self::Right...
Learn Simple Rust
2020-10-21
~19 min read
ismailmaj.github.io
...fn drop(&mut self) {3 let Some(mut node) = self.root.take() else { return; };4 loop {5 let TreeNode { left, right, .. } = *node;6
7 match (left, right) {8 (Some(mut left), Some(right)) => {9 let mut predecessor = &mut left;10 while predecessor.right.is_some() {11 predecessor = predecessor.right.as...
Observations/Thoughts
2023-11-08
~3 min read
rustc-dev-guide.rust-lang.org
...https://forge.rust-lang.org/policies/llm-usage.html
Examples of "obvious" LLM tells are:
• PR descriptions that are completely wrong/don't match the code.
• PR descriptions that state the exact tests that were run (e.g. ./x test --stage 1 tests/ui/<the-new-test-name>.rs) or...
Guide to Rustc Development
Book
2024-01-01
~4 min read
pwy.io
...loop {
ui.paint();
match ui.react() {
Event::DeleteSelectedTask => {
tasks.remove(/* ... */);
// ugh, `task_nodes` has been moved to `ui.set_root()`, it's not
// accessible anymore here:
// task_nodes.remove(/* ... */);
}
}
}
My initial demos used an Arc<RwLock<...>>:
fn main() {
/* ... */
let task_nodes = tasks.iter().map(task).collect();
let task_nodes = Arc...
Observations/Thoughts
2025-08-20
~21 min read