Guest User

Untitled

a guest
Jan 17th, 2019
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.49 KB | None | 0 0
  1. use std::fmt;
  2. fn transpose(matrixces: Matrix) -> (Matrix) {
  3. let Matrix(f1, f2, f3, f4) = matrixces;
  4. Matrix(f1, f3, f2, f4)
  5. }
  6. #[derive(Debug)]
  7. struct Matrix(f32, f32, f32, f32);
  8. impl fmt::Display for Matrix {
  9. fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
  10. write!(f, "({} {})\n({} {})", self.0, self.1, self.2, self.3)
  11. }
  12. }
  13. fn main() {
  14. let matrix = Matrix(1.1, 1.2, 2.1, 2.2);
  15. println!("Matrix:\n{}", matrix);
  16. println!("Transpose: \n{}", transpose(matrix));
  17. }
Add Comment
Please, Sign In to add comment