From 04b4e482659366b042ea2cae462e45f72271438c Mon Sep 17 00:00:00 2001 From: LoganDark Date: Mon, 12 Apr 2021 14:12:39 -0700 Subject: [PATCH] Derive `Default`, `Hash`, and `Eq` for some dpi types (#1833) * Derive more things * Changelog entry --- CHANGELOG.md | 1 + src/dpi.rs | 8 ++++---- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d88de9d9..a14bc047 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -23,6 +23,7 @@ - On Windows, added `WindowBuilderExtWindows::with_owner_window` to allow creating popup windows. - On Windows, added `WindowExtWindows::set_enable` to allow creating modal popup windows. - On macOS, emit `RedrawRequested` events immediately while the window is being resized. +- Implement `Default`, `Hash`, and `Eq` for `LogicalPosition`, `PhysicalPosition`, `LogicalSize`, and `PhysicalSize`. # 0.24.0 (2020-12-09) diff --git a/src/dpi.rs b/src/dpi.rs index ed30abb7..ff0b0c95 100644 --- a/src/dpi.rs +++ b/src/dpi.rs @@ -163,7 +163,7 @@ pub fn validate_scale_factor(scale_factor: f64) -> bool { /// The position is stored as floats, so please be careful. Casting floats to integers truncates the /// fractional part, which can cause noticable issues. To help with that, an `Into<(i32, i32)>` /// implementation is provided which does the rounding for you. -#[derive(Debug, Copy, Clone, PartialEq)] +#[derive(Debug, Copy, Clone, Eq, PartialEq, Default, Hash)] #[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] pub struct LogicalPosition

{ pub x: P, @@ -228,7 +228,7 @@ impl Into<[X; 2]> for LogicalPosition

{ } /// A position represented in physical pixels. -#[derive(Debug, Copy, Clone, PartialEq)] +#[derive(Debug, Copy, Clone, Eq, PartialEq, Default, Hash)] #[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] pub struct PhysicalPosition

{ pub x: P, @@ -293,7 +293,7 @@ impl Into<[X; 2]> for PhysicalPosition

{ } /// A size represented in logical pixels. -#[derive(Debug, Copy, Clone, PartialEq)] +#[derive(Debug, Copy, Clone, Eq, PartialEq, Default, Hash)] #[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] pub struct LogicalSize

{ pub width: P, @@ -358,7 +358,7 @@ impl Into<[X; 2]> for LogicalSize

{ } /// A size represented in physical pixels. -#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] +#[derive(Debug, Copy, Clone, Eq, PartialEq, Default, Hash)] #[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] pub struct PhysicalSize

{ pub width: P,