mirror of
https://github.com/nushell/nushell.git
synced 2025-08-19 08:31:29 +02:00
nothing variable (#527)
* nothing variable * corrected comments * added color to nothing like bool * compare nothing with values * comparison tests
This commit is contained in:
@@ -1141,13 +1141,18 @@ impl Value {
|
||||
val: matches!(ordering, Ordering::Equal),
|
||||
span,
|
||||
}),
|
||||
None => Err(ShellError::OperatorMismatch {
|
||||
op_span: op,
|
||||
lhs_ty: self.get_type(),
|
||||
lhs_span: self.span()?,
|
||||
rhs_ty: rhs.get_type(),
|
||||
rhs_span: rhs.span()?,
|
||||
}),
|
||||
None => match (self, rhs) {
|
||||
(Value::Nothing { .. }, _) | (_, Value::Nothing { .. }) => {
|
||||
Ok(Value::Bool { val: false, span })
|
||||
}
|
||||
_ => Err(ShellError::OperatorMismatch {
|
||||
op_span: op,
|
||||
lhs_ty: self.get_type(),
|
||||
lhs_span: self.span()?,
|
||||
rhs_ty: rhs.get_type(),
|
||||
rhs_span: rhs.span()?,
|
||||
}),
|
||||
},
|
||||
}
|
||||
}
|
||||
pub fn ne(&self, op: Span, rhs: &Value) -> Result<Value, ShellError> {
|
||||
@@ -1162,13 +1167,18 @@ impl Value {
|
||||
val: !matches!(ordering, Ordering::Equal),
|
||||
span,
|
||||
}),
|
||||
None => Err(ShellError::OperatorMismatch {
|
||||
op_span: op,
|
||||
lhs_ty: self.get_type(),
|
||||
lhs_span: self.span()?,
|
||||
rhs_ty: rhs.get_type(),
|
||||
rhs_span: rhs.span()?,
|
||||
}),
|
||||
None => match (self, rhs) {
|
||||
(Value::Nothing { .. }, _) | (_, Value::Nothing { .. }) => {
|
||||
Ok(Value::Bool { val: true, span })
|
||||
}
|
||||
_ => Err(ShellError::OperatorMismatch {
|
||||
op_span: op,
|
||||
lhs_ty: self.get_type(),
|
||||
lhs_span: self.span()?,
|
||||
rhs_ty: rhs.get_type(),
|
||||
rhs_span: rhs.span()?,
|
||||
}),
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user