mirror of
https://github.com/nushell/nushell
synced 2024-12-27 05:23:11 +00:00
Add more pattern types to matcher (#8605)
# Description Add float, string, and date patterns to matcher. This could probably use some tests 😅 # User-Facing Changes _(List of all changes that impact the user experience here. This helps us keep track of breaking changes.)_ # Tests + Formatting Don't forget to add tests that cover your changes. Make sure you've run and fixed any issues with these commands: - `cargo fmt --all -- --check` to check standard code formatting (`cargo fmt --all` applies these changes) - `cargo clippy --workspace -- -D warnings -D clippy::unwrap_used -A clippy::needless_collect` to check that you're using the standard code style - `cargo test --workspace` to check that all tests pass > **Note** > from `nushell` you can also use the `toolkit` as follows > ```bash > use toolkit.nu # or use an `env_change` hook to activate it automatically > toolkit check pr > ``` # After Submitting If your PR had any user-facing changes, update [the documentation](https://github.com/nushell/nushell.github.io) after the PR is merged, if necessary. This will help us keep the docs up to date.
This commit is contained in:
parent
c0648a83be
commit
aab31833a2
1 changed files with 21 additions and 0 deletions
|
@ -77,6 +77,13 @@ impl Matcher for Pattern {
|
|||
false
|
||||
}
|
||||
}
|
||||
Expr::Float(x) => {
|
||||
if let Value::Float { val, .. } = &value {
|
||||
x == val
|
||||
} else {
|
||||
false
|
||||
}
|
||||
}
|
||||
Expr::Binary(x) => {
|
||||
if let Value::Binary { val, .. } = &value {
|
||||
x == val
|
||||
|
@ -91,6 +98,20 @@ impl Matcher for Pattern {
|
|||
false
|
||||
}
|
||||
}
|
||||
Expr::String(x) => {
|
||||
if let Value::String { val, .. } = &value {
|
||||
x == val
|
||||
} else {
|
||||
false
|
||||
}
|
||||
}
|
||||
Expr::DateTime(x) => {
|
||||
if let Value::Date { val, .. } = &value {
|
||||
x == val
|
||||
} else {
|
||||
false
|
||||
}
|
||||
}
|
||||
Expr::ValueWithUnit(amount, unit) => {
|
||||
if let Value::Filesize { val, .. } = &value {
|
||||
// FIXME: we probably want this math in one place that both the
|
||||
|
|
Loading…
Reference in a new issue