-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add examples for platform path (#42)
- Loading branch information
1 parent
81c9b89
commit d3e0948
Showing
3 changed files
with
32 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
use typed_path::PlatformPath; | ||
|
||
fn main() { | ||
// You can create the path like normal, but it is a distinct encoding from Unix/Windows | ||
let path = PlatformPath::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(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,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(); | ||
} |