Use tag for debugger state.

This commit is contained in:
Stephen Chung
2022-05-03 21:55:01 +08:00
parent 4f74d2f96a
commit 516f5a82a0
4 changed files with 21 additions and 41 deletions

View File

@@ -56,17 +56,11 @@ fn test_debugger_state() -> Result<(), Box<EvalAltResult>> {
Dynamic::from_map(state)
},
|mut context, _, _, _, _| {
// Get global runtime state
let global = context.global_runtime_state_mut();
// Get debugger
let debugger = &mut global.debugger;
// Print debugger state - which is an object map
println!("Current state = {}", debugger.state());
println!("Current state = {}", context.tag());
// Modify state
let mut state = debugger.state_mut().write_lock::<Map>().unwrap();
let mut state = context.tag_mut().write_lock::<Map>().unwrap();
let hello = state.get("hello").unwrap().as_int().unwrap();
state.insert("hello".into(), (hello + 1).into());
state.insert("foo".into(), true.into());