proc_strarray

Macro str_repeat0

Source
str_repeat0!() { /* proc-macro */ }
Expand description

Procedural macro proc_strarray::str_repeat0 repeats string literal n times and adds zero termination.

    // This code will repeat string "AB" 2 times.
    use proc_strarray::str_repeat0;
    const S: &str = str_repeat0!("AB", 2);
    assert_eq!(S.len(), 5);
    assert_eq!(S.chars().take(4).collect::<String>(), "ABAB");
    assert_eq!(S.chars().nth(4).unwrap(), 0 as char);