Add Store::insert

This commit is contained in:
Hanno Braun 2024-12-16 21:17:54 +01:00
parent 3b0d56fb52
commit 6437cd930c
3 changed files with 8 additions and 2 deletions

View File

@ -3,7 +3,7 @@ mod primitives;
mod shape;
pub use self::{
operation::{HandleAny, Operation},
operation::{Handle, HandleAny, Operation},
primitives::{Triangle, Vertex},
shape::Shape,
};

View File

@ -107,7 +107,7 @@ impl<'r, NewOps, T> ShapeExtender<'r, NewOps, T> {
NewOps: CombinRight<Handle<T>>,
T: Operation + 'static,
{
let vertex = Handle::new(vertex.into());
let vertex = self.store.insert(vertex.into());
self.sequence.push(OperationInSequence {
operation: vertex.to_any(),

View File

@ -1,5 +1,7 @@
use std::marker::PhantomData;
use crate::geometry::Handle;
pub struct Store<T> {
_t: PhantomData<T>,
}
@ -8,4 +10,8 @@ impl<T> Store<T> {
pub fn new() -> Self {
Self { _t: PhantomData }
}
pub fn insert(&mut self, op: T) -> Handle<T> {
Handle::new(op)
}
}