Skip to content

Commit

Permalink
fix: Fix get_debug_level method to return cloned value instead of usi…
Browse files Browse the repository at this point in the history
…ng lock
  • Loading branch information
oooooba committed Oct 24, 2018
1 parent cdc13ce commit f1c4025
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion repl/src/repl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,7 @@ fn eval_line_(
let debug_level = vm.global_env().get_debug_level();
println!(
"{}",
ValuePrinter::new(&*env, &typ, value.get_variant(), &*debug_level)
ValuePrinter::new(&*env, &typ, value.get_variant(), &debug_level)
.width(80)
.max_level(5)
);
Expand Down
2 changes: 1 addition & 1 deletion src/io.rs
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ fn run_expr(
let typ = execute_value.typ;
let debug_level = vm.global_env().get_debug_level();
IO::Value(record_no_decl!{
value => ValuePrinter::new(&*env, &typ, execute_value.value.get_variant(), &*debug_level).width(80).to_string(),
value => ValuePrinter::new(&*env, &typ, execute_value.value.get_variant(), &debug_level).width(80).to_string(),
typ => typ.to_string()
})
}
Expand Down
4 changes: 2 additions & 2 deletions vm/src/vm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -589,8 +589,8 @@ impl GlobalVmState {
self.env.read().unwrap()
}

pub fn get_debug_level<'b>(&'b self) -> RwLockReadGuard<'b, DebugLevel> {
self.debug_level.read().unwrap()
pub fn get_debug_level(&self) -> DebugLevel {
self.debug_level.read().unwrap().clone()
}

pub fn set_debug_level(&self, debug_level: DebugLevel) {
Expand Down

0 comments on commit f1c4025

Please sign in to comment.