pyo3/impl_/
concat.rs

1/// `concat!` but working with constants
2#[macro_export]
3#[doc(hidden)]
4macro_rules! const_concat {
5    ($e:expr) => {{
6        $e
7    }};
8    ($l:expr, $($r:expr),+ $(,)?) => {{
9        const L: &'static str = $l;
10        const R: &'static str = $crate::impl_::concat::const_concat!($($r),*);
11        const LEN: usize = L.len() + R.len();
12        const fn combine(l: &'static [u8], r: &'static [u8]) -> [u8; LEN] {
13            let mut out = [0u8; LEN];
14            let mut i = 0;
15            while i < l.len() {
16                out[i] = l[i];
17                i += 1;
18            }
19            while i < LEN {
20                out[i] = r[i - l.len()];
21                i += 1;
22            }
23            out
24        }
25        #[allow(unsafe_code)]
26        unsafe { ::std::str::from_utf8_unchecked(&combine(L.as_bytes(), R.as_bytes())) }
27    }}
28}
29
30pub use const_concat;
⚠️ Internal Docs ⚠️ Not Public API 👉 Official Docs Here