clone component configs

This commit is contained in:
Aleksandr 2025-10-12 00:09:20 +03:00
parent 4e3b349e20
commit 7c772e0d48

View file

@ -77,7 +77,7 @@ impl ComponentConfigs {
self.map.get(&type_id).cloned().map(|handle| {
let (cfg, generation) = handle.read::<T>().unwrap();
ComponentConfig {
cfg,
cfg: Arc::new(cfg),
generation,
handle,
}
@ -85,8 +85,9 @@ impl ComponentConfigs {
}
}
#[derive(Clone)]
pub struct ComponentConfig<T> {
cfg: T,
cfg: Arc<T>,
generation: usize,
handle: Arc<ConfigHandle>,
}
@ -121,7 +122,7 @@ impl<T: IsComponentConfig> ComponentConfig<T> {
pub fn force_update(&mut self) -> T {
let (cfg, generation) = self.handle.read::<T>().unwrap();
self.generation = generation;
mem::replace(&mut self.cfg, cfg)
mem::replace(Arc::make_mut(&mut self.cfg), cfg)
}
}