From 8767c789b866a42f0fdd9abe1506e2b65d9df9b4 Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Thu, 4 May 2023 11:14:42 +0200 Subject: [PATCH] Add infrastructure for tracking object insertion --- crates/fj-kernel/src/operations/insert.rs | 27 +++++++++++++++++++++++ crates/fj-kernel/src/operations/mod.rs | 2 +- 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/crates/fj-kernel/src/operations/insert.rs b/crates/fj-kernel/src/operations/insert.rs index 9fe879f46..f76b3d9d6 100644 --- a/crates/fj-kernel/src/operations/insert.rs +++ b/crates/fj-kernel/src/operations/insert.rs @@ -50,3 +50,30 @@ impl_insert!( Surface, surfaces; Vertex, vertices; ); + +/// Indicate whether an object has been inserted +/// +/// Intended to be used as a type parameter bound for structs that need to track +/// whether their contents have been inserted or not. +pub trait IsInserted { + /// The type of the object for which the insertion status is tracked + type T; +} + +/// Indicate that an object has been inserted +/// +/// See [`IsInserted`]. +pub struct IsInsertedYes; + +impl IsInserted for IsInsertedYes { + type T = Handle; +} + +/// Indicate that an object has not been inserted +/// +/// See [`IsInserted`]. +pub struct IsInsertedNo; + +impl IsInserted for IsInsertedNo { + type T = T; +} diff --git a/crates/fj-kernel/src/operations/mod.rs b/crates/fj-kernel/src/operations/mod.rs index 07d818c66..de4ebc596 100644 --- a/crates/fj-kernel/src/operations/mod.rs +++ b/crates/fj-kernel/src/operations/mod.rs @@ -10,7 +10,7 @@ pub use self::{ BuildCycle, BuildFace, BuildHalfEdge, BuildShell, BuildSurface, Polygon, Tetrahedron, }, - insert::Insert, + insert::{Insert, IsInserted, IsInsertedNo, IsInsertedYes}, join::JoinCycle, update::{UpdateCycle, UpdateFace, UpdateHalfEdge, UpdateShell}, };