non_empty_str/macros.rs
1//! Macros used for constructing non-empty strings.
2
3/// Constructs [`Str`] from the given string, panicking if it is empty.
4///
5/// [`Str`]: crate::str::Str
6#[macro_export]
7macro_rules! const_str {
8 ($string: expr) => {
9 $crate::str::Str::new_ok($string).expect($crate::empty::EMPTY)
10 };
11}
12
13/// Similar to [`const_str`], but constructs borrowed [`CowStr`].
14///
15/// [`CowStr`]: crate::cow::CowStr
16#[cfg(any(feature = "alloc", feature = "std"))]
17#[macro_export]
18macro_rules! const_borrowed_str {
19 ($string: expr) => {
20 $crate::cow::CowStr::borrowed_ok($string).expect($crate::empty::EMPTY)
21 };
22}