mirror of
https://github.com/nushell/nushell.git
synced 2025-08-20 17:56:30 +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:
@@ -3540,6 +3540,14 @@ impl Value {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn has(&self, op: Span, rhs: &Value, span: Span) -> Result<Value, ShellError> {
|
||||
rhs.r#in(op, self, span)
|
||||
}
|
||||
|
||||
pub fn not_has(&self, op: Span, rhs: &Value, span: Span) -> Result<Value, ShellError> {
|
||||
rhs.r#not_in(op, self, span)
|
||||
}
|
||||
|
||||
pub fn regex_match(
|
||||
&self,
|
||||
engine_state: &EngineState,
|
||||
|
Reference in New Issue
Block a user