🧑‍💻 Simplify component vector handling

This commit is contained in:
Manuel Cillero 2024-03-16 21:41:04 +01:00
parent 400a492311
commit d7acf0c3d1
17 changed files with 154 additions and 221 deletions

View file

@ -9,7 +9,7 @@ pub struct Submenu {
weight : Weight,
renderable: Renderable,
title : OptionTranslated,
items : TypedComponents<Item>,
items : MixedComponents,
}
impl ComponentTrait for Submenu {
@ -70,15 +70,15 @@ impl Submenu {
self
}
#[rustfmt::skip]
pub fn add_item(mut self, item: Item) -> Self {
self.items.alter_value(TypedOp::Add(OneComponent::with(item)));
#[fn_builder]
pub fn alter_items(&mut self, op: TypedOp<Item>) -> &mut Self {
self.items.alter_typed(op);
self
}
#[fn_builder]
pub fn alter_items(&mut self, op: TypedOp<Item>) -> &mut Self {
self.items.alter_value(op);
#[rustfmt::skip]
pub fn add_item(mut self, item: Item) -> Self {
self.items.alter_value(AnyOp::Add(AnyComponent::with(item)));
self
}
@ -88,7 +88,7 @@ impl Submenu {
&self.title
}
pub fn items(&self) -> &TypedComponents<Item> {
pub fn items(&self) -> &MixedComponents {
&self.items
}
}