From 99b0fab4f0d711ebc958e27731e2d9bcbea6ab55 Mon Sep 17 00:00:00 2001 From: 魏曹先生 <1992414357@qq.com> Date: Fri, 15 May 2026 18:57:27 +0800 Subject: Add `modify` method to `ResourceMarker` trait --- mingling_core/src/asset/global_resource.rs | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'mingling_core/src') diff --git a/mingling_core/src/asset/global_resource.rs b/mingling_core/src/asset/global_resource.rs index 29d2405..8e2ce9f 100644 --- a/mingling_core/src/asset/global_resource.rs +++ b/mingling_core/src/asset/global_resource.rs @@ -4,7 +4,7 @@ use std::{ sync::{Arc, Mutex}, }; -use crate::{ChainProcess, Program, ProgramCollect}; +use crate::{ChainProcess, Program, ProgramCollect, this}; pub(crate) type GlobalResources = Arc>>>; @@ -109,9 +109,12 @@ impl AsRef for GlobalResource pub trait ResourceMarker { fn res_clone(&self) -> Self; fn res_default() -> Self; + fn modify(f: impl FnOnce(&mut Self)) + where + C: ProgramCollect + 'static; } -impl ResourceMarker for T { +impl ResourceMarker for T { fn res_clone(&self) -> Self { Clone::clone(self) } @@ -119,4 +122,11 @@ impl ResourceMarker for T { fn res_default() -> Self { Default::default() } + + fn modify(f: impl FnOnce(&mut Self)) + where + C: ProgramCollect + 'static, + { + this::().modify_res(f); + } } -- cgit