feat(board/edit): Edit structures should implement Default trait

This commit is contained in:
Ellen Emilia Anna Zscheile 2025-08-09 22:44:23 +02:00
parent 791291b82e
commit 6f7586227c
2 changed files with 15 additions and 22 deletions

View File

@ -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<BandName, (Option<BandUid>, Option<BandUid>)>,
}
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 {

View File

@ -38,7 +38,7 @@ pub trait ApplyGeometryEdit<
fn apply(&mut self, edit: &GeometryEdit<DW, SW, BW, CW, Cel, PI, DI, SI, BI>);
}
#[derive(Debug, Clone)]
#[derive(Clone, Debug)]
pub struct GeometryEdit<DW, SW, BW, CW, Cel, PI, DI, SI, BI> {
pub(super) dots: BTreeMap<DI, (Option<DW>, Option<DW>)>,
pub(super) segs: BTreeMap<SI, (Option<((DI, DI), SW)>, Option<((DI, DI), SW)>)>,
@ -53,19 +53,10 @@ pub struct GeometryEdit<DW, SW, BW, CW, Cel, PI, DI, SI, BI> {
BTreeMap<GenericIndex<CW>, (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<DI> + TryInto<SI> + TryInto<BI> + Eq + Ord + Copy,
DI: GetPetgraphIndex + Into<PI> + Eq + Ord + Copy,
SI: GetPetgraphIndex + Into<PI> + Eq + Ord + Copy,
BI: GetPetgraphIndex + Into<PI> + Eq + Ord + Copy,
> GeometryEdit<DW, SW, BW, CW, Cel, PI, DI, SI, BI>
impl<DW, SW, BW, CW, Cel, PI, DI, SI, BI> Default
for GeometryEdit<DW, SW, BW, CW, Cel, PI, DI, SI, BI>
{
pub fn new() -> Self {
fn default() -> Self {
Self {
dots: BTreeMap::new(),
segs: BTreeMap::new(),
@ -75,6 +66,13 @@ impl<
}
}
impl<DW, SW, BW, CW, Cel, PI, DI, SI, BI> GeometryEdit<DW, SW, BW, CW, Cel, PI, DI, SI, BI> {
#[inline(always)]
pub fn new() -> Self {
Self::default()
}
}
impl<
DW: AccessDotWeight + GetLayer,
SW: AccessSegWeight + GetLayer,