Add infrastructure for tracking object insertion

This commit is contained in:
Hanno Braun 2023-05-04 11:14:42 +02:00
parent da5bd11057
commit 8767c789b8
2 changed files with 28 additions and 1 deletions

View File

@ -50,3 +50,30 @@ impl_insert!(
Surface, surfaces; Surface, surfaces;
Vertex, vertices; 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<T>;
}
/// Indicate that an object has been inserted
///
/// See [`IsInserted`].
pub struct IsInsertedYes;
impl IsInserted for IsInsertedYes {
type T<T> = Handle<T>;
}
/// Indicate that an object has not been inserted
///
/// See [`IsInserted`].
pub struct IsInsertedNo;
impl IsInserted for IsInsertedNo {
type T<T> = T;
}

View File

@ -10,7 +10,7 @@ pub use self::{
BuildCycle, BuildFace, BuildHalfEdge, BuildShell, BuildSurface, BuildCycle, BuildFace, BuildHalfEdge, BuildShell, BuildSurface,
Polygon, Tetrahedron, Polygon, Tetrahedron,
}, },
insert::Insert, insert::{Insert, IsInserted, IsInsertedNo, IsInsertedYes},
join::JoinCycle, join::JoinCycle,
update::{UpdateCycle, UpdateFace, UpdateHalfEdge, UpdateShell}, update::{UpdateCycle, UpdateFace, UpdateHalfEdge, UpdateShell},
}; };