Post

A Type Stronger than the Sum of its Components

Small wrapper types around Rust’s Path::Component variants can make path APIs express what they actually accept. NormalComponent lets a join operation reject . and .. components by construction instead of taking an unrestricted OsStr; a separate parent-directory type can represent the .. step explicitly.

The article also explains why lexical path cleanup is not always safe: symlinks and Windows verbatim paths can change what normalization means. r/rust readers welcomed the practical example, and Rust library-team member Josh Triplett used the thread to invite the author to help rewrite standard-library path support. The discussion also dug into Windows’ special treatment of .. and the limits of representing enum subsets as types.