chipsenkbeil / typed-path

Provides typed variants of Path and PathBuf for Unix and Windows
38 stars 6 forks source link

`impl AsRef<std::path::Path> for Utf8NativePath` #12

Closed Nemo157 closed 1 year ago

Nemo157 commented 1 year ago

I have a tool where I'm having to deal with both unix and native paths together (and converting between them). When interacting with the filesystem I want to obviously only use the native paths, but since I'm having to go via .as_str() there's nothing actually enforcing this. If there was the AsRef<Path> impl for only the correct encoding then I would have some implicit checks that I'm using the correct variant.

chipsenkbeil commented 1 year ago

@Nemo157 added AsRef<Path> for Utf8NativePath and Utf8NativePathBuf alongside From<Utf8NativePathBuf> for PathBuf. You can find this included in the newly-published 0.4.1 of the crate.

See the 0.4.1 AsRef doc example for more information.

Let me know if you need anything else!