pub fn pad_table<T: Clone>(
tab: &Vec<Vec<T>>,
el: T,
padding: ((i32, i32), (i32, i32)),
) -> Vec<Vec<T>>Expand description
Pads a table with an element by some specified dimensions.
Clones the table while doing so, so may not be efficient.
§Arguments
tab- The table to be padded.el- The element with which to pad the vector.((left, right), (top, bottom))- The amount to pad in each direction.
§Example
use cgrustplot::helper::arrays::pad_table;
let result = pad_table(&vec![vec![1, 2], vec![3, 4]], 0, ((0, 2), (1, 1)));
assert_eq!(result, vec![vec![0, 0, 0, 0], vec![1, 2, 0, 0], vec![3, 4, 0, 0], vec![0, 0, 0, 0]]);§Notes
Unlike padded_vec, pad_table pads BY a dimension, not TO a specified dimension.
Input table must be rectangular, but may have a size of zero.