forked from extern/nushell
Remove 'empty' block support reminders, for now. (#5214)
This commit is contained in:
committed by
GitHub
parent
07893e01c1
commit
7a7aa310aa
@ -56,6 +56,7 @@ impl Command for Empty {
|
||||
}),
|
||||
},
|
||||
Example {
|
||||
// TODO: revisit empty cell path semantics for a record.
|
||||
description: "Check if more than one column are empty",
|
||||
example: "[[meal size]; [arepa small] [taco '']] | empty? meal size",
|
||||
result: Some(Value::Bool {
|
||||
@ -125,30 +126,15 @@ fn empty(
|
||||
span: head,
|
||||
}
|
||||
.into_pipeline_data()),
|
||||
PipelineData::Value(value, ..) => {
|
||||
let answer = is_empty(value);
|
||||
|
||||
Ok(Value::Bool {
|
||||
val: answer,
|
||||
span: head,
|
||||
}
|
||||
.into_pipeline_data())
|
||||
PipelineData::Value(value, ..) => Ok(Value::Bool {
|
||||
val: value.is_empty(),
|
||||
span: head,
|
||||
}
|
||||
.into_pipeline_data()),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn is_empty(value: Value) -> bool {
|
||||
match value {
|
||||
Value::List { vals, .. } => vals.is_empty(),
|
||||
Value::String { val, .. } => val.is_empty(),
|
||||
Value::Binary { val, .. } => val.is_empty(),
|
||||
Value::Nothing { .. } => true,
|
||||
Value::Record { cols, .. } => cols.is_empty(),
|
||||
_ => false,
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
Reference in New Issue
Block a user