mirror of
https://github.com/nushell/nushell.git
synced 2025-06-30 22:50:14 +02:00
# Description Previously, `par-each` acted like a `flatmap`: first mapping the data, then applying a `flatten`. This is unlike `each`, which just maps the data. Now `par-each` works like `each` in this regard, leaving nested data unflattened. Fixes #8497 # User-Facing Changes Previously: `[1 2 3] | par-each {|e| [$e, $e] }` --> `[1,1,2,2,3,3]` Now: `[1 2 3] | par-each {|e| [$e, $e] }` --> `[[1,1],[2,2],[3,3]]` # Tests This adds one test that verifies the lack of flattening for `par-each`.
This commit is contained in:
@ -59,6 +59,7 @@ mod network;
|
||||
mod nu_check;
|
||||
mod open;
|
||||
mod p;
|
||||
mod par_each;
|
||||
mod parse;
|
||||
mod path;
|
||||
mod platform;
|
||||
|
12
crates/nu-command/tests/commands/par_each.rs
Normal file
12
crates/nu-command/tests/commands/par_each.rs
Normal file
@ -0,0 +1,12 @@
|
||||
use nu_test_support::{nu, pipeline};
|
||||
|
||||
#[test]
|
||||
fn par_each_does_not_flatten_nested_structures() {
|
||||
// This is a regression test for issue #8497
|
||||
let actual = nu!(
|
||||
cwd: ".", pipeline(
|
||||
r#"[1 2 3] | par-each { |it| [$it, $it] } | sort | to json --raw"#
|
||||
));
|
||||
|
||||
assert_eq!(actual.out, "[[1,1],[2,2],[3,3]]");
|
||||
}
|
Reference in New Issue
Block a user