From 6ecf702d68bfe4402dd0a9a362afccffbeef76f4 Mon Sep 17 00:00:00 2001 From: Bruce Mitchener Date: Sat, 10 Aug 2024 18:13:48 +0700 Subject: [PATCH] Derive `Default` on enums. (#103) --- parley/src/layout/data.rs | 9 ++------- parley/src/layout/mod.rs | 9 ++------- 2 files changed, 4 insertions(+), 14 deletions(-) diff --git a/parley/src/layout/data.rs b/parley/src/layout/data.rs index 74ae036..50ffb40 100644 --- a/parley/src/layout/data.rs +++ b/parley/src/layout/data.rs @@ -82,20 +82,15 @@ pub struct RunData { pub advance: f32, } -#[derive(Copy, Clone, PartialEq)] +#[derive(Copy, Clone, Default, PartialEq)] pub enum BreakReason { + #[default] None, Regular, Explicit, Emergency, } -impl Default for BreakReason { - fn default() -> Self { - Self::None - } -} - #[derive(Clone, Default)] pub struct LineData { /// Range of the source text. diff --git a/parley/src/layout/mod.rs b/parley/src/layout/mod.rs index 633b883..d868f99 100644 --- a/parley/src/layout/mod.rs +++ b/parley/src/layout/mod.rs @@ -27,21 +27,16 @@ pub use line::{GlyphRun, LineMetrics, PositionedInlineBox, PositionedLayoutItem} pub use run::RunMetrics; /// Alignment of a layout. -#[derive(Copy, Clone, PartialEq, Eq, Debug)] +#[derive(Copy, Clone, Default, PartialEq, Eq, Debug)] #[repr(u8)] pub enum Alignment { + #[default] Start, Middle, End, Justified, } -impl Default for Alignment { - fn default() -> Self { - Self::Start - } -} - /// Text layout. #[derive(Clone)] pub struct Layout {