sql_support

Function repeat_multi_values

source
pub fn repeat_multi_values(
    num_values: usize,
    vars_per_value: usize,
) -> impl Display
Expand description

Returns a value that formats as num_values instances of (?,?,?,...) (where there are vars_per_value question marks separated by commas in between the ?s).

Panics if vars_per_value is zero (however, num_values is allowed to be zero).

ยงExample

assert_eq!(format!("{}", repeat_multi_values(0, 2)), "");
assert_eq!(format!("{}", repeat_multi_values(1, 5)), "(?,?,?,?,?)");
assert_eq!(format!("{}", repeat_multi_values(2, 3)), "(?,?,?),(?,?,?)");
assert_eq!(format!("{}", repeat_multi_values(3, 1)), "(?),(?),(?)");