diff options
Diffstat (limited to 'src/parse/mod.rs')
| -rw-r--r-- | src/parse/mod.rs | 26 |
1 files changed, 10 insertions, 16 deletions
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<T: Stage> { pub fn decl(name: ExpString, body: Ast<PreExpansion>) -> Ast<PreExpansion> { 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<PreExpansion> { } } -pub fn completion_context<'a, E: Expander>(x: &'a [u8], e: &mut E) -> CompletionContext { +pub fn completion_context<E: Expander>(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<T: Parse>(&mut self) -> Result<T> { @@ -946,8 +941,7 @@ impl Parse for Command<PreExpansion> { Err(e) => Err(e)?, } } - let x = Ok(Self { cmd: path, args }); - x + Ok(Self { cmd: path, args }) } } |
