Hey !
I'm implementing matrix in Rust with that `
use std::fmt::Display ;
struct Matrix<T> {
rows: usize,
columns: usize,
data: Vec<T>,
}
impl<T: Copy + Display + From<i32>> Matrix<T> {
fn new(rows: usize, columns: usize) -> Self {
Self {
rows: rows,
columns: columns,
data: vec![T::from(0); rows*columns],
}
}
}
And now I would like show this matrix like that :
+----------+
| 5 | 7 | 1 |
| 4 | 3 | 2 |
+----------+
However I don't know how do that with any number because if for example there is 100 as value, the text is no longer centered and you have to calculate the number of dashes each time etc ...
Have you an idea to do that ?
Thank you in advance !