Skip to content

Commit 09350d2

Browse files
authored
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.
2 parents 6a2b612 + 80fde23 commit 09350d2

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

library/std/src/path.rs

+6
Original file line numberDiff line numberDiff line change
@@ -268,6 +268,12 @@ pub fn is_separator(c: char) -> bool {
268268
#[stable(feature = "rust1", since = "1.0.0")]
269269
pub const MAIN_SEPARATOR: char = crate::sys::path::MAIN_SEP;
270270

271+
/// The primary separator of path components for the current platform.
272+
///
273+
/// For example, `/` on Unix and `\` on Windows.
274+
#[unstable(feature = "main_separator_str", issue = "94071")]
275+
pub const MAIN_SEPARATOR_STR: &str = crate::sys::path::MAIN_SEP_STR;
276+
271277
////////////////////////////////////////////////////////////////////////////////
272278
// Misc helpers
273279
////////////////////////////////////////////////////////////////////////////////

0 commit comments

Comments
 (0)