macro_rules! with_state {
($state:expr => $block:block) => { ... };
}Expand description
便利宏,用于在指定作用域内设置 State
§示例
use moduforge_rules_expression::with_state;
let state = Arc::new(create_test_state());
with_state!(state => {
// 在这个块内,State 是活跃的
let result = isolate.run_standard("someExpression()")?;
// 即使这里发生错误,State 也会被正确清理
});
// State 在这里已经被清理