From 305a95f5570d78164049474a82c54735f3d88957 Mon Sep 17 00:00:00 2001 From: 魏曹先生 <1992414357@qq.com> Date: Wed, 29 Oct 2025 15:19:42 +0800 Subject: update: Action.rs 1. Rename `insert` to `with_data` and `insert_arc` to `with_arc_data` 2. Add new `insert_data` and `insert_arc_data` methods that take &mut self --- crates/system_action/src/action.rs | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'crates/system_action') diff --git a/crates/system_action/src/action.rs b/crates/system_action/src/action.rs index 9eef1db..ef1bf11 100644 --- a/crates/system_action/src/action.rs +++ b/crates/system_action/src/action.rs @@ -130,17 +130,27 @@ impl ActionContext { } /// Insert arbitrary data in the context - pub fn insert(mut self, value: T) -> Self { + pub fn with_data(mut self, value: T) -> Self { self.data.insert(TypeId::of::(), Arc::new(value)); self } /// Insert arbitrary data as Arc in the context - pub fn insert_arc(mut self, value: Arc) -> Self { + pub fn with_arc_data(mut self, value: Arc) -> Self { self.data.insert(TypeId::of::(), value); self } + /// Insert arbitrary data in the context + pub fn insert_data(&mut self, value: T) { + self.data.insert(TypeId::of::(), Arc::new(value)); + } + + /// Insert arbitrary data as Arc in the context + pub fn insert_arc_data(&mut self, value: Arc) { + self.data.insert(TypeId::of::(), value); + } + /// Get arbitrary data from the context pub fn get(&self) -> Option<&T> { self.data -- cgit