forked from M-Labs/nalgebra
Make OPoint call T::fmt
to respect formatting modifiers (#1336)
This commit is contained in:
parent
1e0cb7bc09
commit
6dce471297
@ -511,10 +511,11 @@ where
|
||||
|
||||
let mut it = self.coords.iter();
|
||||
|
||||
write!(f, "{}", *it.next().unwrap())?;
|
||||
<T as fmt::Display>::fmt(it.next().unwrap(), f)?;
|
||||
|
||||
for comp in it {
|
||||
write!(f, ", {}", *comp)?;
|
||||
write!(f, ", ")?;
|
||||
<T as fmt::Display>::fmt(comp, f)?;
|
||||
}
|
||||
|
||||
write!(f, "}}")
|
||||
|
@ -92,3 +92,11 @@ fn to_homogeneous() {
|
||||
|
||||
assert_eq!(a.to_homogeneous(), expected);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn display_fmt_respects_modifiers() {
|
||||
let p = Point3::new(1.23, 3.45, 5.67);
|
||||
assert_eq!(&format!("{p}"), "{1.23, 3.45, 5.67}");
|
||||
assert_eq!(&format!("{p:.1}"), "{1.2, 3.5, 5.7}");
|
||||
assert_eq!(&format!("{p:.0}"), "{1, 3, 6}");
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user