mirror of
https://github.com/nushell/nushell.git
synced 2025-08-09 02:45:08 +02:00
Add new operators has
and not-has
(#14841)
# Description This PR add 2 new operators, `has` and `not-has`. They are basically `in` and `not-in` with the order of operands swapped. Motivation for this was the awkward way of searching for rows that contain an item using `where` ```nushell [[name, children]; [foo, [a, b, c]], [bar [d, e, f]]] | where ("e" in $it.children) ``` vs ```nushell [[name, children]; [foo, [a, b, c]], [bar [d, e, f]]] | where children has "e" ``` # User-Facing Changes Added `has` and `not-has` operators, mirroring `in` and `not-in`. # Tests + Formatting - 🟢 toolkit fmt - 🟢 toolkit clippy - 🟢 toolkit test - 🟢 toolkit test stdlib # After Submitting
This commit is contained in:
@ -952,6 +952,8 @@ fn binary_op(
|
||||
}
|
||||
Comparison::In => lhs_val.r#in(op_span, &rhs_val, span)?,
|
||||
Comparison::NotIn => lhs_val.not_in(op_span, &rhs_val, span)?,
|
||||
Comparison::Has => lhs_val.has(op_span, &rhs_val, span)?,
|
||||
Comparison::NotHas => lhs_val.not_has(op_span, &rhs_val, span)?,
|
||||
Comparison::StartsWith => lhs_val.starts_with(op_span, &rhs_val, span)?,
|
||||
Comparison::EndsWith => lhs_val.ends_with(op_span, &rhs_val, span)?,
|
||||
},
|
||||
|
Reference in New Issue
Block a user