From 6437cd930c23f5a26f5368683c6ba8f26d5dce9a Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Mon, 16 Dec 2024 21:17:54 +0100 Subject: [PATCH] Add `Store::insert` --- experiments/2024-12-09/src/geometry/mod.rs | 2 +- experiments/2024-12-09/src/geometry/shape.rs | 2 +- experiments/2024-12-09/src/storage.rs | 6 ++++++ 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/experiments/2024-12-09/src/geometry/mod.rs b/experiments/2024-12-09/src/geometry/mod.rs index f259c79cc..6d3652a9b 100644 --- a/experiments/2024-12-09/src/geometry/mod.rs +++ b/experiments/2024-12-09/src/geometry/mod.rs @@ -3,7 +3,7 @@ mod primitives; mod shape; pub use self::{ - operation::{HandleAny, Operation}, + operation::{Handle, HandleAny, Operation}, primitives::{Triangle, Vertex}, shape::Shape, }; diff --git a/experiments/2024-12-09/src/geometry/shape.rs b/experiments/2024-12-09/src/geometry/shape.rs index 19a129888..93b7a34ae 100644 --- a/experiments/2024-12-09/src/geometry/shape.rs +++ b/experiments/2024-12-09/src/geometry/shape.rs @@ -107,7 +107,7 @@ impl<'r, NewOps, T> ShapeExtender<'r, NewOps, T> { NewOps: CombinRight>, T: Operation + 'static, { - let vertex = Handle::new(vertex.into()); + let vertex = self.store.insert(vertex.into()); self.sequence.push(OperationInSequence { operation: vertex.to_any(), diff --git a/experiments/2024-12-09/src/storage.rs b/experiments/2024-12-09/src/storage.rs index 8e43309fd..c4678d28b 100644 --- a/experiments/2024-12-09/src/storage.rs +++ b/experiments/2024-12-09/src/storage.rs @@ -1,5 +1,7 @@ use std::marker::PhantomData; +use crate::geometry::Handle; + pub struct Store { _t: PhantomData, } @@ -8,4 +10,8 @@ impl Store { pub fn new() -> Self { Self { _t: PhantomData } } + + pub fn insert(&mut self, op: T) -> Handle { + Handle::new(op) + } }