unpack_split!() { /* proc-macro */ }Expand description
A procedural macro to split the string and return tuple, where you know the number of arguments, thus making it easy to unpack.
This macro takes exactly two arguments, both of which should be valid Rust expressions that evaluate to str types. The macro will expand to the tuple, including value of first argument repeated N times, where N is arguments_number value of second argument.
§Examples
Use the macro to split the string:
use easify_macros::unpack_split;
let result = unpack_split!("hello,my,name", ",");
assert_eq!(result, ("hello", "my", "name"));use easify_macros::unpack_split;
let some_text = "hello,world";
let result = unpack_split!(some_text, 2);
assert_eq!(result, ("hello", "world"));§Panics
The macro will cause arguments_number compile-time error if not exactly two arguments are provided.
// This will fail to compile
// let result = unpack_split!("hello,world");