From 54239c55ae0d8f9afe23dcc68d3dd5baf4662f3e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=C3=A9ctor=20Ram=C3=B3n=20Jim=C3=A9nez?= Date: Thu, 30 Oct 2025 23:46:59 +0100 Subject: [PATCH] Derive `Default` implementations wherever possible --- core/src/window/position.rs | 9 ++------- examples/game_of_life/src/main.rs | 13 ++++++------- examples/todos/src/main.rs | 9 ++------- 3 files changed, 10 insertions(+), 21 deletions(-) diff --git a/core/src/window/position.rs b/core/src/window/position.rs index 2b31a5e2..50148ea1 100644 --- a/core/src/window/position.rs +++ b/core/src/window/position.rs @@ -1,9 +1,10 @@ use crate::{Point, Size}; /// The position of a window in a given screen. -#[derive(Debug, Clone, Copy)] +#[derive(Debug, Clone, Copy, Default)] pub enum Position { /// The platform-specific default position for a new window. + #[default] Default, /// The window is completely centered on the screen. Centered, @@ -22,9 +23,3 @@ pub enum Position { /// [`Specific`]: Self::Specific SpecificWith(fn(Size, Size) -> Point), } - -impl Default for Position { - fn default() -> Self { - Self::Default - } -} diff --git a/examples/game_of_life/src/main.rs b/examples/game_of_life/src/main.rs index d27ee62e..8e865a5c 100644 --- a/examples/game_of_life/src/main.rs +++ b/examples/game_of_life/src/main.rs @@ -882,16 +882,15 @@ mod grid { } } + #[derive(Default)] pub enum Interaction { + #[default] None, Drawing, Erasing, - Panning { translation: Vector, start: Point }, - } - - impl Default for Interaction { - fn default() -> Self { - Self::None - } + Panning { + translation: Vector, + start: Point, + }, } } diff --git a/examples/todos/src/main.rs b/examples/todos/src/main.rs index 168c5c81..6dee5b66 100644 --- a/examples/todos/src/main.rs +++ b/examples/todos/src/main.rs @@ -285,18 +285,13 @@ struct Task { state: TaskState, } -#[derive(Debug, Clone)] +#[derive(Debug, Clone, Default)] pub enum TaskState { + #[default] Idle, Editing, } -impl Default for TaskState { - fn default() -> Self { - Self::Idle - } -} - #[derive(Debug, Clone)] pub enum TaskMessage { Completed(bool),