The Path type and similar also need the IString treatment when used in an environment that wants more immutability. Basically, copy the string module, add some Path-specific utilities, and then have a better experience with them.
In particular, the methods like canonicalize and read_dir should be mirrored to return IPath as opposed to be defaulted to via Deref to Path and PathBuf. This will let users stay in the immutable world a bit longer. Also a new method should be put in place (just like in &Path) to allow easy conversion from &str and such.
Some methods operate on OsString/OsStr. It might be preferable to cover them as well, but I am not sure if IOsString is desired. Maybe methods like file_name_lossy and into_iter_lossy should be added instead, that would give users IString instead.
The
Pathtype and similar also need theIStringtreatment when used in an environment that wants more immutability. Basically, copy thestringmodule, add somePath-specific utilities, and then have a better experience with them.In particular, the methods like
canonicalizeandread_dirshould be mirrored to returnIPathas opposed to be defaulted to viaDereftoPathandPathBuf. This will let users stay in the immutable world a bit longer. Also anewmethod should be put in place (just like in&Path) to allow easy conversion from&strand such.Some methods operate on
OsString/OsStr. It might be preferable to cover them as well, but I am not sure ifIOsStringis desired. Maybe methods likefile_name_lossyandinto_iter_lossyshould be added instead, that would give usersIStringinstead.