mirror of https://github.com/01-edu/public.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Chris
348649c54a
|
4 years ago | |
---|---|---|
.. | ||
README.md | 4 years ago |
README.md
matrix_display
Instructions
Use the Matrix struct given in the expected struct and implement the std::fmt::Display
trait so it prints the matrix like in the usage.
The associated function new
that creates a matrix from a slice of slices also has to be implemented.
Expected Functions and Struct
pub struct Matrix(pub Vec<Vec<i32>>);
impl Matrix {
pub fn new(slice: &[&[i32]]) -> Self {
}
}
use std::fmt;
impl fmt::Display for Matrix {
}
Usage
Here is a possible program to test your function
fn main() {
let matrix = Matrix::new(&[&[1, 2, 3], &[4, 5, 6], &[7, 8, 9]]);
println!("{}", matrix);
}
And it's output:
student@ubuntu:~/[[ROOT]]/test$ cargo run
(1 2 3)
(4 5 6)
(7 8 9)
student@ubuntu:~/[[ROOT]]/test$