diff --git a/src/board/edit.rs b/src/board/edit.rs index a809392..ba793d5 100644 --- a/src/board/edit.rs +++ b/src/board/edit.rs @@ -6,16 +6,14 @@ use std::collections::BTreeMap; use crate::{board::BandName, drawing::band::BandUid, geometry::edit::Edit, layout::LayoutEdit}; -#[derive(Debug, Clone)] +#[derive(Debug, Clone, Default)] pub struct BoardDataEdit { pub(super) bands: BTreeMap, Option)>, } impl BoardDataEdit { pub fn new() -> Self { - Self { - bands: BTreeMap::new(), - } + Self::default() } } @@ -29,7 +27,7 @@ impl Edit for BoardDataEdit { } } -#[derive(Debug, Clone)] +#[derive(Debug, Clone, Default)] pub struct BoardEdit { pub data_edit: BoardDataEdit, pub layout_edit: LayoutEdit, @@ -37,10 +35,7 @@ pub struct BoardEdit { impl BoardEdit { pub fn new() -> Self { - Self { - data_edit: BoardDataEdit::new(), - layout_edit: LayoutEdit::new(), - } + Self::default() } pub fn new_from_edits(data_edit: BoardDataEdit, layout_edit: LayoutEdit) -> Self { diff --git a/src/geometry/edit.rs b/src/geometry/edit.rs index 3091e42..d43a016 100644 --- a/src/geometry/edit.rs +++ b/src/geometry/edit.rs @@ -38,7 +38,7 @@ pub trait ApplyGeometryEdit< fn apply(&mut self, edit: &GeometryEdit); } -#[derive(Debug, Clone)] +#[derive(Clone, Debug)] pub struct GeometryEdit { pub(super) dots: BTreeMap, Option)>, pub(super) segs: BTreeMap, Option<((DI, DI), SW)>)>, @@ -53,19 +53,10 @@ pub struct GeometryEdit { BTreeMap, (Option<(Vec<(Cel, PI)>, CW)>, Option<(Vec<(Cel, PI)>, CW)>)>, } -impl< - DW: AccessDotWeight + GetLayer, - SW: AccessSegWeight + GetLayer, - BW: AccessBendWeight + GetLayer, - CW: Clone, - Cel: Copy, - PI: GetPetgraphIndex + TryInto + TryInto + TryInto + Eq + Ord + Copy, - DI: GetPetgraphIndex + Into + Eq + Ord + Copy, - SI: GetPetgraphIndex + Into + Eq + Ord + Copy, - BI: GetPetgraphIndex + Into + Eq + Ord + Copy, - > GeometryEdit +impl Default + for GeometryEdit { - pub fn new() -> Self { + fn default() -> Self { Self { dots: BTreeMap::new(), segs: BTreeMap::new(), @@ -75,6 +66,13 @@ impl< } } +impl GeometryEdit { + #[inline(always)] + pub fn new() -> Self { + Self::default() + } +} + impl< DW: AccessDotWeight + GetLayer, SW: AccessSegWeight + GetLayer,