diff --git a/app-proto/src/assembly.rs b/app-proto/src/assembly.rs index 8217922..6c4aeb7 100644 --- a/app-proto/src/assembly.rs +++ b/app-proto/src/assembly.rs @@ -7,13 +7,17 @@ use web_sys::{console, wasm_bindgen::JsValue}; /* DEBUG */ use crate::engine::{realize_gram, PartialMatrix}; +// the types of the keys we use to access an assembly's elements and constraints +pub type ElementKey = usize; +pub type ConstraintKey = usize; + #[derive(Clone, PartialEq)] pub struct Element { pub id: String, pub label: String, pub color: [f32; 3], pub representation: DVector, - pub constraints: BTreeSet, + pub constraints: BTreeSet, // internal properties, not reflected in any view pub index: usize @@ -21,7 +25,7 @@ pub struct Element { #[derive(Clone)] pub struct Constraint { - pub subjects: (usize, usize), + pub subjects: (ElementKey, ElementKey), pub rep: Signal, pub rep_text: Signal, pub rep_valid: Signal, @@ -36,7 +40,7 @@ pub struct Assembly { pub constraints: Signal>, // indexing - pub elements_by_id: Signal> + pub elements_by_id: Signal> } impl Assembly { diff --git a/app-proto/src/main.rs b/app-proto/src/main.rs index 2c71a83..897f9d4 100644 --- a/app-proto/src/main.rs +++ b/app-proto/src/main.rs @@ -8,14 +8,14 @@ use rustc_hash::FxHashSet; use sycamore::prelude::*; use add_remove::AddRemove; -use assembly::Assembly; +use assembly::{Assembly, ElementKey}; use display::Display; use outline::Outline; #[derive(Clone)] struct AppState { assembly: Assembly, - selection: Signal> + selection: Signal> } impl AppState { diff --git a/app-proto/src/outline.rs b/app-proto/src/outline.rs index 98b422f..0a8816d 100644 --- a/app-proto/src/outline.rs +++ b/app-proto/src/outline.rs @@ -150,7 +150,7 @@ pub fn Outline() -> View { ul(class="constraints") { Keyed( list=elt.constraints.into_iter().collect::>(), - view=move |c_key: usize| { + view=move |c_key| { let c_state = use_context::(); let assembly = &c_state.assembly; let cst = assembly.constraints.with(|csts| csts[c_key].clone());