Macro to_str

macro_rules! to_str {
    ($x: expr) => { ... };
}
Expand description

Converts a value to a string slice.

The input type must be one of

This macro is const-context only.

ยงExamples

const A: &str = const_str::to_str!("A");
assert_eq!(A, "A");

const B: &str = const_str::to_str!('ๆˆ‘');
assert_eq!(B, "ๆˆ‘");

const C: &str = const_str::to_str!(true);
assert_eq!(C, "true");

const D: &str = const_str::to_str!(1_u8 + 1);
assert_eq!(D, "2");

const E: &str = const_str::to_str!(-21_i32 * 2);
assert_eq!(E, "-42")