Top all-time · #25886
Home on 0xAtticus
Personal blog · 0xatticus.comprogrammingsystems
Home on 0xAtticus is a personal blog at 0xatticus.com about programming and systems. Since 2025, 3 different Hacker News readers have linked it 3 times. The last post was in 2024, but the archive is still widely read.
Too few sampled comments (3) to say how often HN recommends it.?
Why HN links it
HN readers link this blog's posts on Rust's niche optimization, which explain how the compiler stores enum variants in invalid bit patterns of other types. Comments cite the posts without judging the writing.
Summarised by Claude from a sample of 3 HN comments that link here. Each comment is marked recommending, critical or neutral (citing without judging); how this works.
0xAtticus computer blog
Most-linked posts?
- /posts/understanding_rust_niche/3 people · 3 mentions · first linked 2025-04-10
What Hacker News says?
You can encode not-a-bool, not-a-(utf-8)-string and not-an-enum using one of the invalid bit patterns – that's exactly what the Rust compiler can do with its "niche optimization": https://www.0xatticus.com/posts/understanding_rust_niche/
Comment linking /posts/understanding_rust_niche/
on “Stuffed-Na(a)N: stuff your NaNs”> Outside of dataless enums, this is the only datatype with this behaviour. Note that there are non-zero integer types that can also be used in this way, like NonZeroU8 https://doc.rust-lang.org/std/num/type.NonZeroU8.html . The NULL pointer is also used as a niche, and you can create your own as well, as documented in https://www.0xatticus.com/posts/understanding_rust_niche/
Comment linking /posts/understanding_rust_niche/
on “A surprising enum size optimization in the Rust compiler”> The compiler isn't ignoring your new types True, I didn't meant to imply you can just ignore types; I meant to say that the equivalent operations on a naked vs wrapped value return equivalent assembly. It's one of those zero cost abstraction. You can writ your newtype wrapper and it will be just as if you wrote implementations by hand. > My favourite as a Unix person is Option<OwnedFd>. Yeah, but that's a bit diff…
Comment linking /posts/understanding_rust_niche/
on “The repercussions of missing an Ampersand in C++ and Rust”