Implement std::fmt::Display for iced::Radians (#2446)

* Implement `std::fmt::Display` for Radians

* Add ` rad` to the end of all displayed strings.

Co-authored-by: Héctor Ramón <hector0193@gmail.com>

---------

Co-authored-by: Héctor Ramón <hector0193@gmail.com>
This commit is contained in:
SolidStateDj 2024-06-18 13:02:15 -04:00 committed by GitHub
parent 368b15f708
commit 19db068bbb
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -1,6 +1,7 @@
use crate::{Point, Rectangle, Vector};
use std::f32::consts::{FRAC_PI_2, PI};
use std::fmt::Display;
use std::ops::{Add, AddAssign, Div, Mul, RangeInclusive, Rem, Sub, SubAssign};
/// Degrees
@ -237,3 +238,9 @@ impl PartialOrd<f32> for Radians {
self.0.partial_cmp(other)
}
}
impl Display for Radians {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(f, "{} rad", self.0)
}
}