From 1361e3088224860b143755e9fe1f1d7ce033e476 Mon Sep 17 00:00:00 2001 From: Jonas Maier <> Date: Tue, 10 Mar 2026 18:03:39 +0100 Subject: clippy --- src/parse/mod.rs | 26 ++++++++++---------------- 1 file changed, 10 insertions(+), 16 deletions(-) (limited to 'src/parse/mod.rs') diff --git a/src/parse/mod.rs b/src/parse/mod.rs index 4250caf..0df624f 100644 --- a/src/parse/mod.rs +++ b/src/parse/mod.rs @@ -41,7 +41,7 @@ pub enum Ast { pub fn decl(name: ExpString, body: Ast) -> Ast { Ast::FunDecl(FunDecl { - name: name, + name, body: FunBody { body: Box::new(body), }, @@ -411,10 +411,10 @@ impl ExpString { } fn is_symbol(x: u8) -> bool { - match x { - b';' | b'|' | b'{' | b'}' | b'$' | b'(' | b')' | b'\'' | b'"' => true, - _ => false, - } + matches!( + x, + b';' | b'|' | b'{' | b'}' | b'$' | b'(' | b')' | b'\'' | b'"' + ) } fn is_var_begin(x: u8) -> bool { @@ -618,10 +618,8 @@ impl Parse for ExpString { let cmd = Ast::parse(b)?; b.spaces(); - if b.is_empty() { - if !b.is_completion() { - return Err(ParseError::Expected(')')); - } + if b.is_empty() && !b.is_completion() { + return Err(ParseError::Expected(')')); } if b.has() && b.peek() == b')' { @@ -799,7 +797,7 @@ impl Pipes { } } -pub fn completion_context<'a, E: Expander>(x: &'a [u8], e: &mut E) -> CompletionContext { +pub fn completion_context(x: &[u8], e: &mut E) -> CompletionContext { let mut cursor = Cursor::new(x, ParseMode::Completion); let ast = Ast::parse(&mut cursor); @@ -900,10 +898,7 @@ impl<'a> Cursor<'a> { } fn is_completion(&self) -> bool { - match self.mode { - ParseMode::Completion => true, - _ => false, - } + matches!(self.mode, ParseMode::Completion) } fn parse(&mut self) -> Result { @@ -946,8 +941,7 @@ impl Parse for Command { Err(e) => Err(e)?, } } - let x = Ok(Self { cmd: path, args }); - x + Ok(Self { cmd: path, args }) } } -- cgit v1.2.3