Skip to main content

std/sys/path/
mod.rs

1// There's a lot of necessary redundancy in separator definition. Consolidated into a macro to
2// prevent transcription errors.
3macro_rules! path_separator_bytes {
4    ($($sep:literal),+) => (
5        pub const SEPARATORS: &[char] = &[$($sep as char,)+];
6        pub const SEPARATORS_STR: &[&str] = &[$(
7            match str::from_utf8(&[$sep]) {
8                Ok(s) => s,
9                Err(_) => panic!("path_separator_bytes must be ASCII bytes"),
10            }
11        ),+];
12
13        #[inline]
14        pub const fn is_sep_byte(b: u8) -> bool {
15            $(b == $sep) ||+
16        }
17    )
18}
19
20cfg_select! {
21    target_os = "windows" => {
22        mod windows;
23        mod windows_prefix;
24        pub use windows::*;
25    }
26    all(target_vendor = "fortanix", target_env = "sgx") => {
27        mod sgx;
28        pub use sgx::*;
29    }
30    target_os = "solid_asp3" => {
31        mod unsupported_backslash;
32        pub use unsupported_backslash::*;
33    }
34    target_os = "uefi" => {
35        mod uefi;
36        pub use uefi::*;
37    }
38    target_os = "cygwin" => {
39        mod cygwin;
40        mod windows_prefix;
41        pub use cygwin::*;
42    }
43    _ => {
44        mod unix;
45        pub use unix::*;
46    }
47}