Function with_state_async

Source
pub async fn with_state_async<S, T, F, Fut>(state: Arc<S>, future: F) -> T
where S: Send + Sync + 'static, F: FnOnce() -> Fut, Fut: Future<Output = T>,
Expand description

异步版本的 State 守卫便利函数

§参数

  • state - 要设置的 State 对象
  • future - 要在 State 上下文中执行的异步操作

§返回值

返回异步操作的结果

§示例

use mf_rules_expression::functions::with_state_async;

let state = Arc::new(State::default());

let result = with_state_async(state, async {
    // aync block
}).await;