Simplify tuple flattening and destructuring
The `flatten_tuple` function was unnecessarily recursive. It can now simply return the elements of the tuple directly. The VM's destructuring logic has been updated to handle nested destructuring more efficiently. A new integration test case for multi-level destructuring has been added.
This commit is contained in:
@@ -369,4 +369,25 @@ mod tests {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_multi_level_destructuring() {
|
||||
let env = Environment::new();
|
||||
let source = "(do
|
||||
(def pipe (fn [conf]
|
||||
(do
|
||||
(def [str s] conf)
|
||||
(def [f ss] s)
|
||||
[\"Symbol:\" str \"field:\" f \"id:\" ss]
|
||||
)
|
||||
)
|
||||
)
|
||||
(pipe [\"btc\" [:close \"cls\"]]))";
|
||||
|
||||
let res = env.run_script(source).unwrap();
|
||||
assert_eq!(
|
||||
format!("{}", res),
|
||||
"[\"Symbol:\" \"btc\" \"field:\" :close \"id:\" \"cls\"]"
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user