From 19db068bbbebcda1756720525da247f35bd3a5e0 Mon Sep 17 00:00:00 2001 From: SolidStateDj Date: Tue, 18 Jun 2024 13:02:15 -0400 Subject: [PATCH] Implement `std::fmt::Display` for `iced::Radians` (#2446) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Implement `std::fmt::Display` for Radians * Add ` rad` to the end of all displayed strings. Co-authored-by: Héctor Ramón --------- Co-authored-by: Héctor Ramón --- core/src/angle.rs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/core/src/angle.rs b/core/src/angle.rs index 9c8a9b2448..0882ae8007 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 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) + } +}