From 7c772e0d48a66865d665dc405a516aa32dc12eb8 Mon Sep 17 00:00:00 2001 From: Aleksandr Date: Sun, 12 Oct 2025 00:09:20 +0300 Subject: [PATCH] clone component configs --- src/component_configs.rs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) 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) } }