macro_rules! row {
() => { ... };
( $i:ident, $($tail:tt)* ) => { ... };
( $i:ident ) => { ... };
( $k:ident: $v:expr ) => { ... };
( $k:ident: $v:expr, $($tail:tt)* ) => { ... };
( $k:expr => $v:expr ) => { ... };
( $k:expr => $v:expr, $($tail:tt)* ) => { ... };
}
Expand description
This macro is a convenient way to pass row into a block.
let mut block = Block::new();
block.push(row!{customer_id: 1, amount: 2, account_name: "foo"})?;
block.push(row!{customer_id: 4, amount: 4, account_name: "bar"})?;
block.push(row!{customer_id: 5, amount: 5, account_name: "baz"})?;
you can also use Vec<(String, Value)>
to construct row to insert into a block:
let mut block = Block::new();
for i in 1..10 {
let mut row = Vec::new();
for j in 1..10 {
row.push((format!("#{}", j), Value::from(i * j)));
}
block.push(row)?;
}
assert_eq!(block.row_count(), 9);