mirror of
https://github.com/nushell/nushell.git
synced 2025-08-09 12:15:42 +02:00
use let-else
syntax where possible (#8886)
# Description this pr changes some `if-let`s to `let-else`s # User-Facing Changes none
This commit is contained in:
@ -669,9 +669,7 @@ pub fn parse_alias(
|
||||
return alias_pipeline;
|
||||
}
|
||||
|
||||
let alias_name_expr = if let Some(expr) = alias_call.positional_nth(0) {
|
||||
expr
|
||||
} else {
|
||||
let Some(alias_name_expr) = alias_call.positional_nth(0) else {
|
||||
working_set.error(ParseError::UnknownState(
|
||||
"Missing positional after call check".to_string(),
|
||||
span(spans),
|
||||
@ -932,9 +930,7 @@ pub fn parse_export_in_module(
|
||||
return (garbage_pipeline(spans), vec![]);
|
||||
};
|
||||
|
||||
let export_decl_id = if let Some(id) = working_set.find_decl(b"export", &Type::Any) {
|
||||
id
|
||||
} else {
|
||||
let Some(export_decl_id) = working_set.find_decl(b"export", &Type::Any) else {
|
||||
working_set.error(ParseError::InternalError(
|
||||
"missing export command".into(),
|
||||
export_span,
|
||||
|
@ -2880,9 +2880,7 @@ pub fn parse_type(_working_set: &StateWorkingSet, bytes: &[u8]) -> Type {
|
||||
}
|
||||
|
||||
pub fn parse_import_pattern(working_set: &mut StateWorkingSet, spans: &[Span]) -> Expression {
|
||||
let head_span = if let Some(head_span) = spans.get(0) {
|
||||
head_span
|
||||
} else {
|
||||
let Some(head_span) = spans.get(0) else {
|
||||
working_set.error(ParseError::WrongImportPattern(span(spans)));
|
||||
return garbage(span(spans));
|
||||
};
|
||||
|
Reference in New Issue
Block a user