Macro const_str::to_str[][src]

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

Converts a value to a string slice.

The input type must be one of

  • &str
  • char
  • bool
  • u8, u16, u32, u128, usize
  • i8, i16, i32, i128, isize

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")