From 28b1ecb8e936de8c2d0b2788815204dd60f261ec Mon Sep 17 00:00:00 2001 From: Aaron Fenyes Date: Sat, 28 Sep 2024 13:28:53 -0700 Subject: [PATCH] App: use element insertion method in test --- app-proto/full-interface/src/main.rs | 68 ++++++++++++++-------------- 1 file changed, 34 insertions(+), 34 deletions(-) diff --git a/app-proto/full-interface/src/main.rs b/app-proto/full-interface/src/main.rs index e867ad3..5ed9d30 100644 --- a/app-proto/full-interface/src/main.rs +++ b/app-proto/full-interface/src/main.rs @@ -31,43 +31,43 @@ impl AppState { fn main() { sycamore::render(|| { let state = AppState::new(); - let key_a = state.assembly.elements.update( - |elts| elts.insert( - Element { - id: String::from("wing_a"), - label: String::from("Wing A"), - color: [1.00_f32, 0.25_f32, 0.00_f32], - rep: DVector::::from_column_slice(&[0.5, 0.5, 0.0, 0.5, -0.25]), - constraints: BTreeSet::default() - } - ) + let assemb = &state.assembly; + let _ = assemb.try_insert_element( + Element { + id: String::from("wing_a"), + label: String::from("Wing A"), + color: [1.00_f32, 0.25_f32, 0.00_f32], + rep: DVector::::from_column_slice(&[0.5, 0.5, 0.0, 0.5, -0.25]), + constraints: BTreeSet::default() + } ); - let key_b = state.assembly.elements.update( - |elts| elts.insert( - Element { - id: String::from("wing_b"), - label: String::from("Wing B"), - color: [0.00_f32, 0.25_f32, 1.00_f32], - rep: DVector::::from_column_slice(&[-0.5, -0.5, 0.0, 0.5, -0.25]), - constraints: BTreeSet::default() - }, - ) + let _ = assemb.try_insert_element( + Element { + id: String::from("wing_b"), + label: String::from("Wing B"), + color: [0.00_f32, 0.25_f32, 1.00_f32], + rep: DVector::::from_column_slice(&[-0.5, -0.5, 0.0, 0.5, -0.25]), + constraints: BTreeSet::default() + } ); - state.assembly.elements.update( - |elts| elts.insert( - Element { - id: String::from("central"), - label: String::from("Central"), - color: [0.75_f32, 0.75_f32, 0.75_f32], - rep: DVector::::from_column_slice(&[0.0, 0.0, 0.0, 0.4, -0.625]), - constraints: BTreeSet::default() - } - ) + let _ = assemb.try_insert_element( + Element { + id: String::from("central"), + label: String::from("Central"), + color: [0.75_f32, 0.75_f32, 0.75_f32], + rep: DVector::::from_column_slice(&[0.0, 0.0, 0.0, 0.4, -0.625]), + constraints: BTreeSet::default() + } + ); + assemb.insert_constraint( + Constraint { + args: ( + assemb.elements_by_id.with(|elts_by_id| elts_by_id["wing_a"]), + assemb.elements_by_id.with(|elts_by_id| elts_by_id["wing_b"]) + ), + rep: 0.5 + } ); - state.assembly.insert_constraint(Constraint { - args: (key_a, key_b), - rep: 0.5 - }); provide_context(state); view! {