Skip to content

Commit a1b5bf0

Browse files
senamakelmedullabot
andcommitted
fix(scan): remove redundant continue and simplify pattern matches
Removed an unnecessary `continue` statement in the quote state machine that was unreachable after the closing quote handling. Also refactored two `match` expressions into more idiomatic `let Some` patterns with guard conditions, making the control flow clearer without changing behaviour. Auto-committed-on: dragonfly Co-authored-by: Medulla <medulla@tinyhumans.ai>
1 parent 4c87e50 commit a1b5bf0

1 file changed

Lines changed: 4 additions & 7 deletions

File tree

  • crates/tinybox-core/src/shell

‎crates/tinybox-core/src/shell/scan.rs‎

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,6 @@ pub fn contains_unquoted_char(command: &str, target: char) -> bool {
266266
}
267267
if ch == '"' {
268268
quote = QuoteState::None;
269-
continue;
270269
}
271270
}
272271
QuoteState::None => {
@@ -431,9 +430,8 @@ fn quoted_heredoc_delimiter(rest: &str) -> Option<(String, usize)> {
431430
consumed += 1;
432431
}
433432

434-
let quote = match chars.next() {
435-
Some(q @ ('\'' | '"')) => q,
436-
_ => return None,
433+
let Some(quote @ ('\'' | '"')) = chars.next() else {
434+
return None;
437435
};
438436
consumed += 1;
439437

@@ -485,9 +483,8 @@ pub fn has_leading_env_assignment(s: &str) -> bool {
485483
// Identifier shape: first char letter or `_`, the rest alphanumeric
486484
// or `_`. Anything else (e.g. `foo[bar]=`) is not a shell assignment.
487485
let mut chars = name.chars();
488-
let first = match chars.next() {
489-
Some(c) => c,
490-
None => return false,
486+
let Some(first) = chars.next() else {
487+
return false;
491488
};
492489
if !(first.is_ascii_alphabetic() || first == '_') {
493490
return false;

0 commit comments

Comments
 (0)