diff --git a/src/component_configs.rs b/src/component_configs.rs index 3fe0420..c096c66 100644 --- a/src/component_configs.rs +++ b/src/component_configs.rs @@ -77,7 +77,7 @@ impl ComponentConfigs { self.map.get(&type_id).cloned().map(|handle| { let (cfg, generation) = handle.read::().unwrap(); ComponentConfig { - cfg, + cfg: Arc::new(cfg), generation, handle, } @@ -85,8 +85,9 @@ impl ComponentConfigs { } } +#[derive(Clone)] pub struct ComponentConfig { - cfg: T, + cfg: Arc, generation: usize, handle: Arc, } @@ -121,7 +122,7 @@ impl ComponentConfig { pub fn force_update(&mut self) -> T { let (cfg, generation) = self.handle.read::().unwrap(); self.generation = generation; - mem::replace(&mut self.cfg, cfg) + mem::replace(Arc::make_mut(&mut self.cfg), cfg) } }