Skip to content

Commit

Permalink
Rollup merge of #93976 - SUPERCILEX:separator_str, r=yaahc
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
matthiaskrgr authored Feb 17, 2022
2 parents 6a2b612 + 80fde23 commit 09350d2
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions library/std/src/path.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
////////////////////////////////////////////////////////////////////////////////
Expand Down

0 comments on commit 09350d2

Please sign in to comment.