diff options
| author | Matthias Krüger <matthias.krueger@famsik.de> | 2022-02-17 23:00:58 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-02-17 23:00:58 +0100 |
| commit | 09350d2cf0bc3d931b47dfc4fdee69e76a0a50ad (patch) | |
| tree | 103b9e843b3b61c952e6af3d93c1dbbc1702a5ae | |
| parent | 6a2b612590284f2e8fc08117c976e017ddd79d81 (diff) | |
| parent | 80fde23a75513b498f95051719b2c8e0e3afecc4 (diff) | |
| download | rust-09350d2cf0bc3d931b47dfc4fdee69e76a0a50ad.tar.gz rust-09350d2cf0bc3d931b47dfc4fdee69e76a0a50ad.zip | |
Rollup merge of #93976 - SUPERCILEX:separator_str, r=yaahc
Add MAIN_SEPARATOR_STR
Currently, if someone needs access to the path separator as a str, they need to go through this mess:
```rust
unsafe {
std::str::from_utf8_unchecked(slice::from_ref(&(MAIN_SEPARATOR as u8)))
}
```
This PR just re-exports an existing path separator str API.
| -rw-r--r-- | library/std/src/path.rs | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/library/std/src/path.rs b/library/std/src/path.rs index adb8b30ec08..e544608f83c 100644 --- a/library/std/src/path.rs +++ b/library/std/src/path.rs @@ -268,6 +268,12 @@ pub fn is_separator(c: char) -> bool { #[stable(feature = "rust1", since = "1.0.0")] pub const MAIN_SEPARATOR: char = crate::sys::path::MAIN_SEP; +/// The primary separator of path components for the current platform. +/// +/// For example, `/` on Unix and `\` on Windows. +#[unstable(feature = "main_separator_str", issue = "94071")] +pub const MAIN_SEPARATOR_STR: &str = crate::sys::path::MAIN_SEP_STR; + //////////////////////////////////////////////////////////////////////////////// // Misc helpers //////////////////////////////////////////////////////////////////////////////// |
