pub async fn with_state_async<T, F, Fut>(state: Arc<State>, future: F) -> TExpand description
异步版本的 State 守卫便利函数
§参数
state- 要设置的 State 对象future- 要在 State 上下文中执行的异步操作
§返回值
返回异步操作的结果
§示例
use moduforge_rules_expression::functions::with_state_async;
let state = Arc::new(create_test_state());
let result = with_state_async(state, async {
let result1 = isolate.run_standard_with_state("expr1", state.clone()).await?;
let result2 = isolate.run_unary_with_state("expr2", state.clone()).await?;
Ok((result1, result2))
}).await?;