Skip to content

Commit

Permalink
Add Store::insert
Browse files Browse the repository at this point in the history
  • Loading branch information
hannobraun committed Dec 16, 2024
1 parent 3b0d56f commit 6437cd9
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
2 changes: 1 addition & 1 deletion experiments/2024-12-09/src/geometry/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ mod primitives;
mod shape;

pub use self::{
operation::{HandleAny, Operation},
operation::{Handle, HandleAny, Operation},
primitives::{Triangle, Vertex},
shape::Shape,
};
2 changes: 1 addition & 1 deletion experiments/2024-12-09/src/geometry/shape.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down
6 changes: 6 additions & 0 deletions experiments/2024-12-09/src/storage.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
use std::marker::PhantomData;

use crate::geometry::Handle;

pub struct Store<T> {
_t: PhantomData<T>,
}
Expand All @@ -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)
}
}

0 comments on commit 6437cd9

Please sign in to comment.