mirror of
https://github.com/nushell/nushell.git
synced 2025-08-09 05:14:44 +02:00
Use matches!()
for true/false returning match statements (#2176)
This commit is contained in:
@ -74,13 +74,10 @@ impl WholeStreamCommand for Each {
|
||||
}
|
||||
|
||||
fn is_expanded_it_usage(head: &SpannedExpression) -> bool {
|
||||
match &*head {
|
||||
SpannedExpression {
|
||||
expr: Expression::Synthetic(Synthetic::String(s)),
|
||||
..
|
||||
} if s == "expanded-each" => true,
|
||||
_ => false,
|
||||
}
|
||||
matches!(&*head, SpannedExpression {
|
||||
expr: Expression::Synthetic(Synthetic::String(s)),
|
||||
..
|
||||
} if s == "expanded-each")
|
||||
}
|
||||
|
||||
pub async fn process_row(
|
||||
|
@ -90,10 +90,7 @@ impl RangeIterator {
|
||||
curr: range.from.0.item,
|
||||
end: range.to.0.item,
|
||||
tag,
|
||||
is_end_inclusive: match range.to.1 {
|
||||
RangeInclusion::Inclusive => true,
|
||||
RangeInclusion::Exclusive => false,
|
||||
},
|
||||
is_end_inclusive: matches!(range.to.1, RangeInclusion::Inclusive),
|
||||
is_done: false,
|
||||
}
|
||||
}
|
||||
|
@ -100,10 +100,7 @@ impl WholeStreamCommand for KeepUntil {
|
||||
.await;
|
||||
trace!("RESULT = {:?}", result);
|
||||
|
||||
match result {
|
||||
Ok(ref v) if v.is_true() => false,
|
||||
_ => true,
|
||||
}
|
||||
!matches!(result, Ok(ref v) if v.is_true())
|
||||
}
|
||||
})
|
||||
.to_output_stream())
|
||||
|
@ -100,10 +100,7 @@ impl WholeStreamCommand for KeepWhile {
|
||||
.await;
|
||||
trace!("RESULT = {:?}", result);
|
||||
|
||||
match result {
|
||||
Ok(ref v) if v.is_true() => true,
|
||||
_ => false,
|
||||
}
|
||||
matches!(result, Ok(ref v) if v.is_true())
|
||||
}
|
||||
})
|
||||
.to_output_stream())
|
||||
|
@ -99,10 +99,7 @@ impl WholeStreamCommand for SkipUntil {
|
||||
.await;
|
||||
trace!("RESULT = {:?}", result);
|
||||
|
||||
match result {
|
||||
Ok(ref v) if v.is_true() => false, // stop skipping
|
||||
_ => true,
|
||||
}
|
||||
!matches!(result, Ok(ref v) if v.is_true())
|
||||
}
|
||||
})
|
||||
.to_output_stream())
|
||||
|
@ -99,10 +99,7 @@ impl WholeStreamCommand for SkipWhile {
|
||||
.await;
|
||||
trace!("RESULT = {:?}", result);
|
||||
|
||||
match result {
|
||||
Ok(ref v) if v.is_true() => true,
|
||||
_ => false,
|
||||
}
|
||||
matches!(result, Ok(ref v) if v.is_true())
|
||||
}
|
||||
})
|
||||
.to_output_stream())
|
||||
|
@ -38,10 +38,7 @@ fn signature_dict(signature: Signature, tag: impl Into<Tag>) -> Value {
|
||||
let mut sig = TaggedListBuilder::new(&tag);
|
||||
|
||||
for arg in signature.positional.iter() {
|
||||
let is_required = match arg.0 {
|
||||
PositionalType::Mandatory(_, _) => true,
|
||||
PositionalType::Optional(_, _) => false,
|
||||
};
|
||||
let is_required = matches!(arg.0, PositionalType::Mandatory(_, _));
|
||||
|
||||
sig.push_value(for_spec(arg.0.name(), "argument", is_required, &tag));
|
||||
}
|
||||
|
@ -8,10 +8,7 @@ use nu_protocol::{UntaggedValue, Value};
|
||||
use std::path::{Component, Path, PathBuf};
|
||||
|
||||
fn is_value_tagged_dir(value: &Value) -> bool {
|
||||
match &value.value {
|
||||
UntaggedValue::Row(_) | UntaggedValue::Table(_) => true,
|
||||
_ => false,
|
||||
}
|
||||
matches!(&value.value, UntaggedValue::Row(_) | UntaggedValue::Table(_))
|
||||
}
|
||||
|
||||
#[derive(Debug, Eq, Ord, PartialEq, PartialOrd)]
|
||||
|
Reference in New Issue
Block a user