diff options
| author | 魏曹先生 <1992414357@qq.com> | 2026-07-21 03:58:44 +0800 |
|---|---|---|
| committer | 魏曹先生 <1992414357@qq.com> | 2026-07-21 03:58:44 +0800 |
| commit | a3b75b7eeae5e7a0c53b6167bafb75a85fa6d9ce (patch) | |
| tree | 26219f710a5cac52b257f330bcfa29d3b6cae312 /mingling_core/src/asset/global_resource.rs | |
| parent | 57746fc1512400fde467d3ccac4589915341416c (diff) | |
feat(core): return `&mut Self` from builder methods
Enables method chaining for `with_resource`, `with_dispatcher`,
`with_dispatchers`, `with_hook`, and `with_setup`
Diffstat (limited to 'mingling_core/src/asset/global_resource.rs')
| -rw-r--r-- | mingling_core/src/asset/global_resource.rs | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/mingling_core/src/asset/global_resource.rs b/mingling_core/src/asset/global_resource.rs index 29e1136..a610378 100644 --- a/mingling_core/src/asset/global_resource.rs +++ b/mingling_core/src/asset/global_resource.rs @@ -13,10 +13,14 @@ where C: ProgramCollect<Enum = C>, { /// Insert a resource of the given type, cloning the provided value into the store - pub fn with_resource<Res: 'static + Send + Sync + ResourceMarker>(&mut self, res: Res) { + pub fn with_resource<Res: 'static + Send + Sync + ResourceMarker>( + &mut self, + res: Res, + ) -> &mut Self { if let Ok(mut guard) = self.resources.lock() { guard.insert(TypeId::of::<Res>(), Box::new(Arc::new(res))); } + self } /// Modify a resource by type, applying a closure to the resource if present |
