pub type Utf8PlatformPath = Utf8Path<Utf8PlatformEncoding>;
Expand description
Utf8Path
that has the platform’s encoding during compilation.
§Examples
use typed_path::Utf8PlatformPath;
// 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 unix_path = path.with_unix_encoding();
let win_path = path.with_windows_encoding();
Aliased Type§
struct Utf8PlatformPath { /* private fields */ }
Trait Implementations§
Source§impl AsRef<Path> for Utf8PlatformPath
impl AsRef<Path> for Utf8PlatformPath
Source§fn as_ref(&self) -> &StdPath
fn as_ref(&self) -> &StdPath
Converts a platform utf8 path (based on compilation family) into std::path::Path
.
use typed_path::Utf8PlatformPath;
use std::path::Path;
let platform_path = Utf8PlatformPath::new("some_file.txt");
let std_path: &Path = platform_path.as_ref();
assert_eq!(std_path, Path::new("some_file.txt"));