diff options
Diffstat (limited to 'library/core/src')
| -rw-r--r-- | library/core/src/macros/mod.rs | 28 | ||||
| -rw-r--r-- | library/core/src/prelude/v1.rs | 9 |
2 files changed, 37 insertions, 0 deletions
diff --git a/library/core/src/macros/mod.rs b/library/core/src/macros/mod.rs index 993ae723229..b18508186a6 100644 --- a/library/core/src/macros/mod.rs +++ b/library/core/src/macros/mod.rs @@ -967,6 +967,34 @@ pub(crate) mod builtin { ($($e:ident),+ $(,)?) => {{ /* compiler built-in */ }}; } + /// Concatenates literals into a byte slice. + /// + /// This macro takes any number of comma-separated literals, and concatenates them all into + /// one, yielding an expression of type `&[u8, _]`, which represents all of the literals + /// concatenated left-to-right. The literals passed can be any combination of: + /// + /// - byte literals (`b'r'`) + /// - byte strings (`b"Rust"`) + /// - arrays of bytes/numbers (`[b'A', 66, b'C']`) + /// + /// # Examples + /// + /// ``` + /// #![feature(concat_bytes)] + /// + /// # fn main() { + /// let s: &[u8; 6] = concat_bytes!(b'A', b"BC", [68, b'E', 70]); + /// assert_eq!(s, b"ABCDEF"); + /// # } + /// ``` + #[cfg(not(bootstrap))] + #[unstable(feature = "concat_bytes", issue = "87555")] + #[rustc_builtin_macro] + #[macro_export] + macro_rules! concat_bytes { + ($($e:literal),+ $(,)?) => {{ /* compiler built-in */ }}; + } + /// Concatenates literals into a static string slice. /// /// This macro takes any number of comma-separated literals, yielding an diff --git a/library/core/src/prelude/v1.rs b/library/core/src/prelude/v1.rs index 6b51ef5b012..8705eb39468 100644 --- a/library/core/src/prelude/v1.rs +++ b/library/core/src/prelude/v1.rs @@ -61,6 +61,15 @@ pub use crate::{ }; #[unstable( + feature = "concat_bytes", + issue = "87555", + reason = "`concat_bytes` is not stable enough for use and is subject to change" +)] +#[cfg(not(bootstrap))] +#[doc(no_inline)] +pub use crate::concat_bytes; + +#[unstable( feature = "asm", issue = "72016", reason = "inline assembly is not stable enough for use and is subject to change" |
