@@ -266,22 +266,33 @@ impl<'a> Prefix<'a> {
266266/// ```
267267#[ must_use]
268268#[ stable( feature = "rust1" , since = "1.0.0" ) ]
269- pub fn is_separator ( c : char ) -> bool {
269+ #[ rustc_const_unstable( feature = "const_path_separators" , issue = "153106" ) ]
270+ pub const fn is_separator ( c : char ) -> bool {
270271 c. is_ascii ( ) && is_sep_byte ( c as u8 )
271272}
272273
273- /// The primary separator of path components for the current platform.
274- ///
275- /// For example, `/` on Unix and `\` on Windows.
274+ /// All path separators recognized on the current platform, represented as [`char`]s; for example,
275+ /// this is `&['/'][..]` on Unix and `&['\\', '/'][..]` on Windows. The [primary
276+ /// separator](MAIN_SEPARATOR) is always element 0 of the slice.
277+ #[ unstable( feature = "const_path_separators" , issue = "153106" ) ]
278+ pub const SEPARATORS : & [ char ] = crate :: sys:: path:: SEPARATORS ;
279+
280+ /// All path separators recognized on the current platform, represented as [`&str`]s; for example,
281+ /// this is `&["/"][..]` on Unix and `&["\\", "/"][..]` on Windows. The [primary
282+ /// separator](MAIN_SEPARATOR_STR) is always element 0 of the slice.
283+ #[ unstable( feature = "const_path_separators" , issue = "153106" ) ]
284+ pub const SEPARATORS_STR : & [ & str ] = crate :: sys:: path:: SEPARATORS_STR ;
285+
286+ /// The primary separator of path components for the current platform, represented as a [`char`];
287+ /// for example, this is `'/'` on Unix and `'\\'` on Windows.
276288#[ stable( feature = "rust1" , since = "1.0.0" ) ]
277289#[ cfg_attr( not( test) , rustc_diagnostic_item = "path_main_separator" ) ]
278- pub const MAIN_SEPARATOR : char = crate :: sys :: path :: MAIN_SEP ;
290+ pub const MAIN_SEPARATOR : char = SEPARATORS [ 0 ] ;
279291
280- /// The primary separator of path components for the current platform.
281- ///
282- /// For example, `/` on Unix and `\` on Windows.
292+ /// The primary separator of path components for the current platform, represented as a [`&str`];
293+ /// for example, this is `"/"` on Unix and `"\\"` on Windows.
283294#[ stable( feature = "main_separator_str" , since = "1.68.0" ) ]
284- pub const MAIN_SEPARATOR_STR : & str = crate :: sys :: path :: MAIN_SEP_STR ;
295+ pub const MAIN_SEPARATOR_STR : & str = SEPARATORS_STR [ 0 ] ;
285296
286297////////////////////////////////////////////////////////////////////////////////
287298// Misc helpers
0 commit comments