Utf8PlatformPathBuf

Type Alias Utf8PlatformPathBuf 

Source
pub type Utf8PlatformPathBuf = Utf8PathBuf<Utf8PlatformEncoding>;
Expand description

Utf8PathBuf that has the platform’s encoding during compilation.

§Examples

use typed_path::Utf8PlatformPathBuf;

// You can create the pathbuf like normal, but it is a distinct encoding from Unix/Windows
let path = Utf8PlatformPathBuf::from("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§

pub struct Utf8PlatformPathBuf { /* private fields */ }

Trait Implementations§

Source§

impl AsRef<Path> for Utf8PlatformPathBuf

Available on crate feature std and non-target_family=wasm only.
Source§

fn as_ref(&self) -> &StdPath

Converts a platform utf8 pathbuf (based on compilation family) into std::path::Path.

use typed_path::Utf8PlatformPathBuf;
use std::path::Path;

let platform_path_buf = Utf8PlatformPathBuf::from("some_file.txt");
let std_path: &Path = platform_path_buf.as_ref();

assert_eq!(std_path, Path::new("some_file.txt"));