nushell/crates/nu-command
mike 5bfec20244
add match guards (#9621)
## description

this pr adds [match
guards](https://doc.rust-lang.org/reference/expressions/match-expr.html#match-guards)
to match patterns
```nushell
match $x {
   _ if $x starts-with 'nu' => {},
   $x => {}
}
```

these work pretty much like rust's match guards, with few limitations:

1. multiple matches using the `|` are not (yet?) supported
 
```nushell
match $num {
    0 | _ if (is-odd $num) => {},
    _ => {}
}
```

2. blocks cannot be used as guards, (yet?)

```nushell
match $num {
    $x if { $x ** $x == inf } => {},
     _ => {}
}
```

## checklist
- [x] syntax
- [x] syntax highlighting[^1]
- [x] semantics
- [x] tests
- [x] clean up

[^1]: defered for another pr
2023-07-16 12:25:12 +12:00
..
src Refactor path commands (#9687) 2023-07-15 00:04:22 +03:00
tests add match guards (#9621) 2023-07-16 12:25:12 +12:00
Cargo.toml Use is-terminal crate for now (#9670) 2023-07-12 18:15:54 +02:00
LICENSE Fix rest of license year ranges (#8727) 2023-04-04 09:03:29 +12:00