6 hours ago
- The author forked Rust's 'rand' crate to create 'urandom', aiming to reduce papercuts and improve discoverability of everyday operations.
- 'urandom' places the high-level consumer API on a single 'Random' wrapper struct, eliminating the need to import multiple traits for common operations like random range, choose, and shuffle.
- 'urandom' seals its low-level 'Rng' trait, preventing external generators and allowing the crate to optimize algorithms (e.g., Xoshiro) for specific outputs like f32 and f64, achieving up to 31% higher throughput in benchmarks.
- Uniform sampling in 'urandom' uses a unified, unbiased lazy threshold calculation, which is simpler and often faster than 'rand's split approach with separate biased and unbiased paths.