dev_bestia_string_utils/
macros_mod.rs

1// macros_mod.rs
2
3/// short macro `s!()` instead of `&str.to_string` or `format!()`, because that is so common an verbose.  
4/// Equivalents: `String::new()`, `x.to_string()`, `x.to_owned()`, `format!()`...  
5#[macro_export]
6macro_rules! s {
7    () => {
8        String::new()
9    };
10    ($my_str: expr) => {
11        $my_str.to_string()
12    };
13    ($literal: expr, $str_1: expr) => {
14        format!($literal, $str_1)
15    };
16    ($literal: expr, $str_1: expr, $str_2: expr) => {
17        format!($literal, $str_1, $str_2)
18    };
19    ($literal: expr, $str_1: expr, $str_2: expr, $str_3: expr) => {
20        format!($literal, $str_1, $str_2, $str_3)
21    };
22    ($literal: expr, $str_1: expr, $str_2: expr, $str_3: expr, $str_4: expr) => {
23        format!($literal, $str_1, $str_2, $str_3, $str_4)
24    };
25}