async_component_components/
vec.rs

1use std::ops::{Deref, DerefMut};
2
3use async_component_core::AsyncComponent;
4
5#[derive(Debug)]
6pub struct VecComponent<T>(pub Vec<T>);
7
8impl<T> Deref for VecComponent<T> {
9    type Target = Vec<T>;
10
11    fn deref(&self) -> &Self::Target {
12        &self.0
13    }
14}
15
16impl<T> DerefMut for VecComponent<T> {
17    fn deref_mut(&mut self) -> &mut Self::Target {
18        &mut self.0
19    }
20}
21
22impl<T: AsyncComponent> AsyncComponent for VecComponent<T> {
23    fn update_component(&mut self) {
24        for component in &mut self.0 {
25            component.update_component();
26        }
27    }
28}