fj_core/operations/update/
face.rs1use crate::{
2 objects::{Face, Region},
3 operations::{build::Polygon, derive::DeriveFrom, insert::Insert},
4 storage::Handle,
5 Core,
6};
7
8pub trait UpdateFace {
10 #[must_use]
12 fn update_region<T>(
13 &self,
14 update: impl FnOnce(&Handle<Region>, &mut Core) -> T,
15 core: &mut Core,
16 ) -> Self
17 where
18 T: Insert<Inserted = Handle<Region>>;
19}
20
21impl UpdateFace for Face {
22 fn update_region<T>(
23 &self,
24 update: impl FnOnce(&Handle<Region>, &mut Core) -> T,
25 core: &mut Core,
26 ) -> Self
27 where
28 T: Insert<Inserted = Handle<Region>>,
29 {
30 let region = update(self.region(), core);
31 Face::new(
32 self.surface().clone(),
33 region.insert(core).derive_from(self.region(), core),
34 )
35 }
36}
37
38impl<const D: usize> UpdateFace for Polygon<D> {
39 fn update_region<T>(
40 &self,
41 update: impl FnOnce(&Handle<Region>, &mut Core) -> T,
42 core: &mut Core,
43 ) -> Self
44 where
45 T: Insert<Inserted = Handle<Region>>,
46 {
47 self.replace_face(self.face.update_region(update, core))
48 }
49}