diff options
Diffstat (limited to 'utils/src/macros.rs')
| -rw-r--r-- | utils/src/macros.rs | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/utils/src/macros.rs b/utils/src/macros.rs new file mode 100644 index 0000000..f1cb75e --- /dev/null +++ b/utils/src/macros.rs @@ -0,0 +1,14 @@ +/// A macro for creating a `Vec<String>` from string literals. +/// +/// # Examples +/// ``` +/// # use cli_utils::string_vec; +/// let v = string_vec!["hello", "world"]; +/// assert_eq!(v, vec!["hello".to_string(), "world".to_string()]); +/// ``` +#[macro_export] +macro_rules! string_vec { + ($($elem:expr),* $(,)?) => { + vec![$($elem.to_string()),*] + }; +} |
