Update builder method

This commit is contained in:
Hanno Braun 2022-11-11 16:56:12 +01:00
parent 674d33a6ba
commit 73a411d902
2 changed files with 12 additions and 16 deletions

View File

@ -43,11 +43,10 @@ pub trait GlobalVertexBuilder {
) -> Self; ) -> Self;
/// Update partial global vertex from the given surface and position on it /// Update partial global vertex from the given surface and position on it
fn update_from_surface_and_position( fn from_surface_and_position(
&mut self,
surface: &Surface, surface: &Surface,
position: impl Into<Point<2>>, position: impl Into<Point<2>>,
) -> &mut Self; ) -> Self;
} }
impl GlobalVertexBuilder for PartialGlobalVertex { impl GlobalVertexBuilder for PartialGlobalVertex {
@ -66,18 +65,15 @@ impl GlobalVertexBuilder for PartialGlobalVertex {
let position_surface = path.point_from_path_coords(position); let position_surface = path.point_from_path_coords(position);
let mut global_vertex = PartialGlobalVertex::default(); Self::from_surface_and_position(&surface, position_surface)
global_vertex
.update_from_surface_and_position(&surface, position_surface);
global_vertex
} }
fn update_from_surface_and_position( fn from_surface_and_position(
&mut self,
surface: &Surface, surface: &Surface,
position: impl Into<Point<2>>, position: impl Into<Point<2>>,
) -> &mut Self { ) -> Self {
self.position = Some(surface.point_from_surface_coords(position)); PartialGlobalVertex {
self position: Some(surface.point_from_surface_coords(position)),
}
} }
} }

View File

@ -107,10 +107,10 @@ impl PartialSurfaceVertex {
let global_form = self let global_form = self
.global_form .global_form
.update_partial(|mut global_form| { .update_partial(|_| {
global_form PartialGlobalVertex::from_surface_and_position(
.update_from_surface_and_position(&surface, position); &surface, position,
global_form )
}) })
.into_full(objects)?; .into_full(objects)?;