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:
Michael Schimmel
2026-02-19 23:56:50 +01:00
parent 1331aabbe1
commit 30cd73aa63
3 changed files with 16 additions and 16 deletions
+9 -9
View File
@@ -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))