diff options
| author | 魏曹先生 <1992414357@qq.com> | 2026-02-27 06:18:30 +0800 |
|---|---|---|
| committer | 魏曹先生 <1992414357@qq.com> | 2026-02-27 06:18:30 +0800 |
| commit | da1a67d4d32b081fee59f30c43695de21225522a (patch) | |
| tree | 84cdb00e05f4d85f9e441894f846cfaa1b884bd0 /utils/src/lazy_macros.rs | |
| parent | 49f8161fafb636d9d44d2f0878a7429058fb1db6 (diff) | |
Add utility functions and macros
- Add `current_tempfile_path` function to get temporary file paths
- Add `input_with_editor_custom` function that accepts custom editor
- Add `string_vec!` macro for creating `Vec<String>` from literals
Diffstat (limited to 'utils/src/lazy_macros.rs')
| -rw-r--r-- | utils/src/lazy_macros.rs | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/utils/src/lazy_macros.rs b/utils/src/lazy_macros.rs new file mode 100644 index 0000000..1019d0f --- /dev/null +++ b/utils/src/lazy_macros.rs @@ -0,0 +1,13 @@ +/// A macro for creating a `Vec<String>` from string literals. +/// +/// # Examples +/// ``` +/// 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()),*] + }; +} |
