Showing
2 changed files
with
10 additions
and
8 deletions
... | ... | @@ -24,7 +24,7 @@ |
24 | 24 | // |
25 | 25 | use std::cmp::Ordering; |
26 | 26 | use std::convert::{TryFrom, TryInto}; |
27 | -use std::fmt; | |
27 | +use std::fmt::{Formatter, Display}; | |
28 | 28 | use std::num::TryFromIntError; |
29 | 29 | use std::ops::{Add,Sub,Neg,Mul,Div}; |
30 | 30 | |
... | ... | @@ -116,8 +116,8 @@ impl TryInto<(i32, i32)> for Fractional { |
116 | 116 | } |
117 | 117 | } |
118 | 118 | |
119 | -impl fmt::Display for Fractional { | |
120 | - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { | |
119 | +impl Display for Fractional { | |
120 | + fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result { | |
121 | 121 | write!(f, "({}/{})", self.0, self.1) |
122 | 122 | } |
123 | 123 | } | ... | ... |
... | ... | @@ -18,8 +18,9 @@ |
18 | 18 | // You should have received a copy of the GNU General Public License |
19 | 19 | // along with this program. If not, see <http://www.gnu.org/licenses/>. |
20 | 20 | // |
21 | +use std::fmt::{Formatter, Display, Result}; | |
21 | 22 | use std::ops::{Add, Sub, Neg, Mul, Div}; |
22 | -use std::fmt; | |
23 | + | |
23 | 24 | use crate::trigonometry::Trig; |
24 | 25 | |
25 | 26 | #[derive(Debug, Eq, Clone, Copy)] |
... | ... | @@ -61,10 +62,11 @@ where T: Add<Output = T> + Sub<Output = T> + Neg<Output = T> |
61 | 62 | } |
62 | 63 | } |
63 | 64 | |
64 | -impl<T> fmt::Display for Vector<T> | |
65 | -where T: Add + Sub + Neg + Mul + Div + Trig + fmt::Display + Copy { | |
66 | - fn fmt(&self, f :&mut fmt::Formatter<'_>) -> fmt::Result { | |
67 | - write!(f, "({}, {}, {})", self.0, self.1, self.2) | |
65 | +impl<T> Display for Vector<T> | |
66 | +where T: Add + Sub + Neg + Mul + Div + Trig + Display + Copy { | |
67 | + fn fmt(&self, f :&mut Formatter<'_>) -> Result { | |
68 | + let Vector(x, y, z) = self; | |
69 | + write!(f, "({}, {}, {})", x, y, z) | |
68 | 70 | } |
69 | 71 | } |
70 | 72 | ... | ... |
Please
register
or
login
to post a comment