diff options
author | 2024-06-18 13:02:15 -0400 | |
---|---|---|
committer | 2024-06-18 17:02:15 +0000 | |
commit | 19db068bbbebcda1756720525da247f35bd3a5e0 (patch) | |
tree | 9146e9d76e5a4b17ab0cb011cfd9648d06557a53 | |
parent | 368b15f70896b387ae3f072e807b289b36b2d103 (diff) | |
download | iced-19db068bbbebcda1756720525da247f35bd3a5e0.tar.gz iced-19db068bbbebcda1756720525da247f35bd3a5e0.tar.bz2 iced-19db068bbbebcda1756720525da247f35bd3a5e0.zip |
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>
-rw-r--r-- | core/src/angle.rs | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/core/src/angle.rs b/core/src/angle.rs index 9c8a9b24..0882ae80 100644 --- a/core/src/angle.rs +++ b/core/src/angle.rs @@ -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) + } +} |