macro_rules! str_repeat { ($string:expr, $times:expr $(,)*) => { ... }; }
Expand description
Creates a &'static str
by repeating a &'static str
constant times
times
This is evaluated at compile-time.
§Example
use const_format::str_repeat;
{
const OUT: &str = str_repeat!("hi ", 4);
assert_eq!(OUT, "hi hi hi hi ")
}
{
const IN: &str = "bye ";
const REPEAT: usize = 5;
const OUT: &str = str_repeat!(IN, REPEAT);
assert_eq!(OUT, "bye bye bye bye bye ")
}
§Failing
If this macro would produce too large a string, it causes a compile-time error.
ⓘ
const_format::str_repeat!("hello", usize::MAX / 4);