macro_rules! repeat {
($item:expr, $times:expr) => { ... };
}Expand description
A macro for generates a vector containing the repetition of the given expression item for times times.
This macro utilizes a loop to repeatedly push the evaluated item into a vector,
effectively creating a collection with times instances of item.
§Arguments
item: The expression to be repeated.times: The number of times$itemshould be repeated.
§Returns
A vector containing the repeated expressions.
§Example
use macrors::repeat;
let repeat_1 = repeat!("A", 5);
assert_eq!(vec!["A", "A", "A", "A", "A"], repeat_1);
let repeat_2 = repeat!(101, 5);
assert_eq!(vec![101, 101, 101, 101, 101], repeat_2);@since 0.2.0