diff --git a/src/geometry/recording_with_rtree.rs b/src/geometry/recording_with_rtree.rs index bffc757..78e9263 100644 --- a/src/geometry/recording_with_rtree.rs +++ b/src/geometry/recording_with_rtree.rs @@ -33,12 +33,6 @@ pub struct RecordingGeometryWithRtree< geometry_with_rtree: GeometryWithRtree, } -/// inherent associated types are unstable -/// see issue #8995 for more information -macro_rules! OurGeometryEdit { - () => { GeometryEdit } -} - impl< PW: GetWidth + GetLayer + TryInto + TryInto + TryInto + Retag + Copy, DW: AccessDotWeight + GetLayer, @@ -61,7 +55,7 @@ impl< pub fn add_dot + GetLayer>( &mut self, - recorder: &mut OurGeometryEdit!(), + recorder: &mut GeometryEdit, weight: W, ) -> GenericIndex where @@ -82,7 +76,7 @@ impl< pub fn add_seg + GetLayer>( &mut self, - recorder: &mut OurGeometryEdit!(), + recorder: &mut GeometryEdit, from: DI, to: DI, weight: W, @@ -108,7 +102,7 @@ impl< pub fn add_bend + GetLayer>( &mut self, - recorder: &mut OurGeometryEdit!(), + recorder: &mut GeometryEdit, from: DI, to: DI, core: DI, @@ -135,7 +129,7 @@ impl< pub fn add_compound( &mut self, - recorder: &mut OurGeometryEdit!(), + recorder: &mut GeometryEdit, weight: CW, ) -> GenericIndex { let compound = self.geometry_with_rtree.add_compound(weight); @@ -147,7 +141,7 @@ impl< pub fn add_to_compound( &mut self, - recorder: &mut OurGeometryEdit!(), + recorder: &mut GeometryEdit, primitive: GenericIndex, compound: GenericIndex, ) { @@ -168,14 +162,22 @@ impl< .1 = Some((new_members, new_weight)); } - pub fn remove_dot(&mut self, recorder: &mut OurGeometryEdit!(), dot: DI) -> Result<(), ()> { + pub fn remove_dot( + &mut self, + recorder: &mut GeometryEdit, + dot: DI, + ) -> Result<(), ()> { let weight = self.geometry_with_rtree.geometry().dot_weight(dot); self.geometry_with_rtree.remove_dot(dot)?; edit_remove_from_map(&mut recorder.dots, dot, weight); Ok(()) } - pub fn remove_seg(&mut self, recorder: &mut OurGeometryEdit!(), seg: SI) { + pub fn remove_seg( + &mut self, + recorder: &mut GeometryEdit, + seg: SI, + ) { let geometry = self.geometry_with_rtree.geometry(); let weight = geometry.seg_weight(seg); let joints = geometry.seg_joints(seg); @@ -183,7 +185,11 @@ impl< edit_remove_from_map(&mut recorder.segs, seg, (joints, weight)); } - pub fn remove_bend(&mut self, recorder: &mut OurGeometryEdit!(), bend: BI) { + pub fn remove_bend( + &mut self, + recorder: &mut GeometryEdit, + bend: BI, + ) { let geometry = self.geometry_with_rtree.geometry(); let weight = geometry.bend_weight(bend); let joints = geometry.bend_joints(bend); @@ -198,7 +204,7 @@ impl< pub fn remove_compound( &mut self, - recorder: &mut OurGeometryEdit!(), + recorder: &mut GeometryEdit, compound: GenericIndex, ) { let geometry = self.geometry_with_rtree.geometry(); @@ -208,7 +214,12 @@ impl< edit_remove_from_map(&mut recorder.compounds, compound, (members, weight)); } - pub fn move_dot(&mut self, recorder: &mut OurGeometryEdit!(), dot: DI, to: Point) { + pub fn move_dot( + &mut self, + recorder: &mut GeometryEdit, + dot: DI, + to: Point, + ) { let old_weight = self.geometry_with_rtree.geometry().dot_weight(dot); self.geometry_with_rtree.move_dot(dot, to); let new_weight = self.geometry_with_rtree.geometry().dot_weight(dot); @@ -220,8 +231,12 @@ impl< .1 = Some(new_weight); } - fn modify_bend(&mut self, recorder: &mut OurGeometryEdit!(), bend: BI, f: F) - where + fn modify_bend( + &mut self, + recorder: &mut GeometryEdit, + bend: BI, + f: F, + ) where F: FnOnce(&mut GeometryWithRtree, BI), { let geometry = self.geometry_with_rtree.geometry(); @@ -246,13 +261,22 @@ impl< .1 = Some(((new_joints.0, new_joints.1, new_core), new_weight)); } - pub fn shift_bend(&mut self, recorder: &mut OurGeometryEdit!(), bend: BI, offset: f64) { + pub fn shift_bend( + &mut self, + recorder: &mut GeometryEdit, + bend: BI, + offset: f64, + ) { self.modify_bend(recorder, bend, |geometry_with_rtree, bend| { geometry_with_rtree.shift_bend(bend, offset) }); } - pub fn flip_bend(&mut self, recorder: &mut OurGeometryEdit!(), bend: BI) { + pub fn flip_bend( + &mut self, + recorder: &mut GeometryEdit, + bend: BI, + ) { self.modify_bend(recorder, bend, |geometry_with_rtree, bend| { geometry_with_rtree.flip_bend(bend) }); @@ -260,7 +284,7 @@ impl< pub fn reattach_bend( &mut self, - recorder: &mut OurGeometryEdit!(), + recorder: &mut GeometryEdit, bend: BI, maybe_new_inner: Option, ) { @@ -332,7 +356,7 @@ impl< > ApplyGeometryEdit for RecordingGeometryWithRtree { - fn apply(&mut self, edit: &OurGeometryEdit!()) { + fn apply(&mut self, edit: &GeometryEdit) { for (compound, (maybe_old_data, ..)) in &edit.compounds { if maybe_old_data.is_some() { self.geometry_with_rtree.remove_compound(*compound);