nushell/crates/nu-command/src/generators
Wind e281c03403
generate: switch the position of <initial> and <closure>, so the closure can have default parameters (#13393)
# Description
Close: #12083 
Close: #12084 

# User-Facing Changes
It's a breaking change because we have switched the position of
`<initial>` and `<closure>`, after the change, initial value will be
optional. So it's possible to do something like this:

```nushell
> let f = {|fib = [0, 1]| {out: $fib.0, next: [$fib.1, ($fib.0 + $fib.1)]} }
> generate $f | first 5
╭───┬───╮
│ 0 │ 0 │
│ 1 │ 1 │
│ 2 │ 1 │
│ 3 │ 2 │
│ 4 │ 3 │
╰───┴───╯
```

It will also raise error if user don't give initial value, and the
closure don't have default parameter.
```nushell
❯ let f = {|fib| {out: $fib.0, next: [$fib.1, ($fib.0 + $fib.1)]} }
❯ generate $f
Error:   × The initial value is missing
   ╭─[entry #5:1:1]
 1 │ generate $f
   · ────┬───
   ·     ╰── Missing intial value
   ╰────
  help: Provide <initial> value in generate, or assigning default value to closure parameter

```

# Tests + Formatting
Added some test cases.

---------

Co-authored-by: Stefan Holderbach <sholderbach@users.noreply.github.com>
2024-07-19 00:22:28 -07:00
..
cal.rs Internal representation (IR) compiler and evaluator (#13330) 2024-07-10 17:33:59 -07:00
generate.rs generate: switch the position of <initial> and <closure>, so the closure can have default parameters (#13393) 2024-07-19 00:22:28 -07:00
mod.rs remove the unfold command (#10773) 2023-11-17 06:50:20 +08:00
seq_char.rs Add command_prelude module (#12291) 2024-03-26 21:17:30 +00:00
seq_date.rs Fix example wording in seq date (#12665) 2024-04-25 22:12:42 +02:00
seq.rs Add and use new Signals struct (#13314) 2024-07-07 22:29:01 +00:00