Skip to content
Hacker News front page

Rusty thoughts on 'Parse, don't validate'

Rusty thoughts on "Parse, don't validate"

Eli Bendersky revisits the 'Parse, don't validate' pattern in Rust. The key idea: use types like NonEmpty to enforce invariants at compile time, so you never need to re-check emptiness at runtime. Examples from POSIX utilities and rust-analyzer's AbsPathBuf show how to turn validation into parsing. The post doesn't discuss performance numbers or community debates.

Read the original ↗Export Markdown