Files
ez-urandom/IDEAS.md
T
ddidderr d618bd7cc9 docs: add IDEAS.md with ergonomy backlog
Capture a short backlog of ergonomy improvements for the public API so the
ideas don't get lost between sessions. This is a planning document only —
no code changes, and nothing here is committed to as a roadmap.

Items recorded:
- Thread-local global helpers (e.g. `random_u64()`) to avoid threading an
  `OsRandom` through call sites for one-off uses.
- `gen_range` for all integer widths and `Range`/`RangeInclusive` overloads;
  today only `gen_range_u32` exists.
- `fill_bytes(&mut [u8])` so callers don't need to bring `io::Read` into
  scope just to fill a buffer.
- `bool()` and `f64()` (unit interval) helpers.
- Generic `shuffle(&mut [T])` and `choose<T>(&[T]) -> &T`, not just byte
  slices.
- Accept `&str` alphabets directly and drop the ASCII assert by iterating
  `chars()` instead of bytes.
- Loosen `&mut self` to `&self` (interior buffering) or impl `Clone`, so
  multiple call sites can share a handle without borrow-checker friction.
- Preset constructors: `OsRandom::password(len)`, `::hex(len)`,
  `::token(len)`.
2026-04-28 19:38:44 +02:00

759 B

Ergonomy ideas

  • Default / thread_local global: ez_urandom::random_u64() without constructing or threading an OsRandom.
  • gen_range for all int widths (currently only u32) plus a Range / RangeInclusive overload.
  • fill_bytes(&mut [u8]) convenience so callers don't need to import io::Read.
  • bool() / f64() (unit interval) helpers.
  • shuffle(&mut [T]) and choose<T>(&[T]) -> &T — generic, not just bytes.
  • Accept a &str alphabet directly (not just &[u8]) and drop the ASCII assert by iterating chars().
  • Loosen &mut self to &self via interior buffering, or impl Clone, so multiple call sites don't fight the borrow checker.
  • Builder / presets: OsRandom::password(len), ::hex(len), ::token(len).