macro_toolset

Macro str_concat_v2

Source
macro_rules! str_concat_v2 {
    ($($x:expr),*) => { ... };
    (str = $string_initial:expr; $($x:expr),*) => { ... };
    (cap = $cap:expr; $($x:expr),*) => { ... };
    (sep = $sep:expr; $($x:expr),*) => { ... };
}
Expand description

Fast concat String / &str / number.

For details of params accepted, please refers to StringT.

§Examples

// General usage
assert_eq!(
    str_concat_v2!(
        NumStr::hex_default(0xa_usize), // HexStr
        "b", // &str
        "c".to_string(), // String
        1u8, // single number
        '😀', // char
        '�' // char
    ), "abc1😀�"
);
// with initial string
let mut str_initial = "abc".to_string();
str_concat_v2!(str = str_initial; "1", "😀", "�");
assert_eq!(
   str_initial, "abc1😀�"
);

// with capacity
assert_eq!(
   str_concat_v2!(cap = 10; "abc", "1", "😀", "�"), "abc1😀�"
);

// with separator
assert_eq!(
  str_concat_v2!(sep = ","; "abc", "1", "😀", "�"), "abc,1,😀,�"
);