Refactor multiple if let bindings
Replaces nested `if let` statements with sequential `if let` bindings, improving readability. This change is applied to `Dumper::log_bound`, `LambdaCollector::visit_bound`, `Environment::call_object_method`, and `Environment::call_lambda`.
This commit is contained in:
@@ -233,11 +233,11 @@ impl Environment {
|
||||
let mut vm = VM::new(self.global_values.clone());
|
||||
let result = vm.run(node)?;
|
||||
|
||||
if let Value::Object(obj) = &result {
|
||||
if let Some(closure) = obj.as_any().downcast_ref::<crate::ast::vm::Closure>() {
|
||||
// Execute the script body
|
||||
return vm.run(&closure.function_node);
|
||||
}
|
||||
if let Value::Object(obj) = &result
|
||||
&& let Some(closure) = obj.as_any().downcast_ref::<crate::ast::vm::Closure>()
|
||||
{
|
||||
// Execute the script body
|
||||
return vm.run(&closure.function_node);
|
||||
}
|
||||
|
||||
Ok(result)
|
||||
@@ -267,10 +267,10 @@ impl Environment {
|
||||
let mut result = vm.run_with_observer(&mut observer, &linked);
|
||||
|
||||
// If result is a closure (script entry), execute the body too
|
||||
if let Ok(Value::Object(obj)) = &result {
|
||||
if let Some(closure) = obj.as_any().downcast_ref::<crate::ast::vm::Closure>() {
|
||||
result = vm.run_with_observer(&mut observer, &closure.function_node);
|
||||
}
|
||||
if let Ok(Value::Object(obj)) = &result
|
||||
&& let Some(closure) = obj.as_any().downcast_ref::<crate::ast::vm::Closure>()
|
||||
{
|
||||
result = vm.run_with_observer(&mut observer, &closure.function_node);
|
||||
}
|
||||
|
||||
Ok((result, observer.logs))
|
||||
|
||||
Reference in New Issue
Block a user