macro_toolset

Macro str_concat

Source
macro_rules! str_concat {
    ($($x:expr),*) => { ... };
    (str = $str:expr; $($x:expr),*) => { ... };
    (cap = $cap:expr; $($x:expr),*) => { ... };
    (sep = $sep:expr; $($x:expr),*) => { ... };
}
๐Ÿ‘ŽDeprecated since 0.8.0-rc.1: Use string_v2 instead, v1 will be removed in 0.9.0.
Expand description

Fast concat String / &str / number.

For details of params accepted, please refers to StringExtT.

ยงExamples

// General usage
assert_eq!(
    str_concat!(
        NumStr::hex_default(0xa_usize), // HexStr
        "b", // &str
        "c".to_string(), // String
        1u8, // single number
        '๐Ÿ˜€', // char
        '๏ฟฝ' // char
    ), "abc1๐Ÿ˜€๏ฟฝ"
);
// with initial string
assert_eq!(
   str_concat!(str = "abc"; "1", "๐Ÿ˜€", "๏ฟฝ"), "abc1๐Ÿ˜€๏ฟฝ"
);

// with capacity
assert_eq!(
   str_concat!(cap = 10; "abc", "1", "๐Ÿ˜€", "๏ฟฝ"), "abc1๐Ÿ˜€๏ฟฝ"
);

// with separator
assert_eq!(
  str_concat!(sep = ","; "abc", "1", "๐Ÿ˜€", "๏ฟฝ"), "abc,1,๐Ÿ˜€,๏ฟฝ"
);