sql_support

Function repeat_display

source
pub fn repeat_display<F>(
    count: usize,
    sep: &str,
    fmt_one: F,
) -> RepeatDisplay<'_, F>
where F: Fn(usize, &mut Formatter<'_>) -> Result,
Expand description

Construct a RepeatDisplay that will repeatedly call fmt_one with a formatter count times, separated by sep.

ยงExample

assert_eq!(format!("{}", repeat_display(1, ",", |i, f| write!(f, "({},?)", i))),
           "(0,?)");
assert_eq!(format!("{}", repeat_display(2, ",", |i, f| write!(f, "({},?)", i))),
           "(0,?),(1,?)");
assert_eq!(format!("{}", repeat_display(3, ",", |i, f| write!(f, "({},?)", i))),
           "(0,?),(1,?),(2,?)");