Time based mutex poisoning

I've recently been asked what was an interesting bug I've run into during a project, and after discarding some boring ones (openssl failing on macos, correct utf8 parsing, 4 variables to set the same limit), I've remembered there was a more fun one. I've written a wrapper over std::collections::HashMap to make entries expirying, aka if I insert a value at t0 = 0s that expires in 5s: em.insert("key", "value", Duration::from_secs(5)) and then I try to get that value at t1 = 6s: ...

January 26, 2026 · 2 min · Nevalicjus

Numeric rand::distr

Rust rand crate has a distr module for distributions, both trait and impls that simplify random generation, like Alphabetic, Alphanumeric. It also includes a SampleString trait that gives us a sample_string fn on it's impl, for generating a sampling string of len n. So, if we want a random alphanumeric string we can just write: 1use rand::distr::{Alphanumeric, SampleString}; 2 3fn main() { 4 println!("{}", Alphanumeric.sample_string(&mut rand::rng(), 20)); 5} This is incredibly useful, but distr doesn't include a Numeric distribution; which you might say isn't needed, since you can: ...

November 7, 2025 · 3 min · Nevalicjus