Skip to content

Commit

Permalink
Implement std::fmt::Display for iced::Radians (#2446)
Browse files Browse the repository at this point in the history
* 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>
  • Loading branch information
SolidStateDj and hecrj committed Jun 18, 2024
1 parent 368b15f commit 19db068
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions core/src/angle.rs
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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)
}
}

0 comments on commit 19db068

Please sign in to comment.