From 77d9a537fdb7cb317d091ac69f1cb8f76e4be29d Mon Sep 17 00:00:00 2001 From: ozkriff Date: Mon, 3 Mar 2014 13:22:14 +0400 Subject: [PATCH] Updated to latest Rust: Implemented Show for Mat{2,3,4} --- src/cgmath/matrix.rs | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/src/cgmath/matrix.rs b/src/cgmath/matrix.rs index f7a757c..b00ce26 100644 --- a/src/cgmath/matrix.rs +++ b/src/cgmath/matrix.rs @@ -15,6 +15,7 @@ //! Column major, square matrix types and traits. +use std::fmt; use std::num::{Zero, zero, One, one, cast, sqrt}; use angle::{Rad, sin, cos, sin_cos}; @@ -720,3 +721,30 @@ ToQuat for Mat3 { } } } + +impl + fmt::Show> fmt::Show for Mat2 { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + write!(f.buf, "[[{}, {}], [{}, {}]]", + self.cr(0, 0), self.cr(0, 1), + self.cr(1, 0), self.cr(1, 1)) + } +} + +impl + fmt::Show> fmt::Show for Mat3 { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + write!(f.buf, "[[{}, {}, {}], [{}, {}, {}], [{}, {}, {}]]", + self.cr(0, 0), self.cr(0, 1), self.cr(0, 2), + self.cr(1, 0), self.cr(1, 1), self.cr(1, 2), + self.cr(2, 0), self.cr(2, 1), self.cr(2, 2)) + } +} + +impl + fmt::Show> fmt::Show for Mat4 { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + write!(f.buf, "[[{}, {}, {}, {}], [{}, {}, {}, {}], [{}, {}, {}, {}], [{}, {}, {}, {}]]", + self.cr(0, 0), self.cr(0, 1), self.cr(0, 2), self.cr(0, 3), + self.cr(1, 0), self.cr(1, 1), self.cr(1, 2), self.cr(1, 3), + self.cr(2, 0), self.cr(2, 1), self.cr(2, 2), self.cr(2, 3), + self.cr(3, 0), self.cr(3, 1), self.cr(3, 2), self.cr(3, 3)) + } +}