diff --git a/fractional/src/fractional.rs b/fractional/src/fractional.rs index 5e0f04c..d177215 100644 --- a/fractional/src/fractional.rs +++ b/fractional/src/fractional.rs @@ -24,7 +24,7 @@ // use std::cmp::Ordering; use std::convert::{TryFrom, TryInto}; -use std::fmt; +use std::fmt::{Formatter, Display}; use std::num::TryFromIntError; use std::ops::{Add,Sub,Neg,Mul,Div}; @@ -116,8 +116,8 @@ impl TryInto<(i32, i32)> for Fractional { } } -impl fmt::Display for Fractional { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { +impl Display for Fractional { + fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result { write!(f, "({}/{})", self.0, self.1) } } diff --git a/fractional/src/vector.rs b/fractional/src/vector.rs index 43bfb54..e56afae 100644 --- a/fractional/src/vector.rs +++ b/fractional/src/vector.rs @@ -18,8 +18,9 @@ // You should have received a copy of the GNU General Public License // along with this program. If not, see . // +use std::fmt::{Formatter, Display, Result}; use std::ops::{Add, Sub, Neg, Mul, Div}; -use std::fmt; + use crate::trigonometry::Trig; #[derive(Debug, Eq, Clone, Copy)] @@ -61,10 +62,11 @@ where T: Add + Sub + Neg } } -impl fmt::Display for Vector -where T: Add + Sub + Neg + Mul + Div + Trig + fmt::Display + Copy { - fn fmt(&self, f :&mut fmt::Formatter<'_>) -> fmt::Result { - write!(f, "({}, {}, {})", self.0, self.1, self.2) +impl Display for Vector +where T: Add + Sub + Neg + Mul + Div + Trig + Display + Copy { + fn fmt(&self, f :&mut Formatter<'_>) -> Result { + let Vector(x, y, z) = self; + write!(f, "({}, {}, {})", x, y, z) } }