Store elements and regulators without keys

Since we're no longer using storage keys to refer to elements and
regulators, we don't need to store these items in keyed collections
anymore.

To keep element and regulator pointers in `BTreeSet` collections, we
implement `Ord` for `Serial` trait objects. As a bonus, this lets us
turn the element-wise regulator collections back into `BTreeSet`.
This commit is contained in:
Aaron Fenyes 2025-05-04 12:24:17 -07:00
parent 8a86038de0
commit c6b628d424
5 changed files with 74 additions and 50 deletions

View file

@ -228,11 +228,15 @@ pub fn Outline() -> View {
let state = use_context::<AppState>();
// list the elements alphabetically by ID
/* TO DO */
// this code is designed to generalize easily to other sort keys. if we only
// ever wanted to sort by ID, we could do that more simply using the
// `elements_by_id` index
let element_list = state.assembly.elements.map(
|elts| elts
.clone()
.into_iter()
.sorted_by_key(|(_, elt)| elt.id().clone())
.sorted_by_key(|elt| elt.id().clone())
.collect()
);
@ -246,10 +250,10 @@ pub fn Outline() -> View {
) {
Keyed(
list=element_list,
view=|(_, elt)| view! {
view=|elt| view! {
ElementOutlineItem(element=elt)
},
key=|(_, elt)| elt.serial()
key=|elt| elt.serial()
)
}
}