typed-path 0.12.3

Provides typed variants of Path and PathBuf for Unix and Windows
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
use typed_path::Utf8PlatformPath;

fn main() {
    // You can create the path like normal, but it is a distinct encoding from Unix/Windows
    let path = Utf8PlatformPath::new("some/path");

    // The path will still behave like normal and even report its underlying encoding
    assert_eq!(path.has_unix_encoding(), cfg!(unix));
    assert_eq!(path.has_windows_encoding(), cfg!(windows));

    // It can still be converted into specific platform paths
    let _ = path.with_unix_encoding();
    let _ = path.with_windows_encoding();
}