From 83e8c17ea744eb1168036f7c77e01c8636671452 Mon Sep 17 00:00:00 2001 From: Ethan Goh <7086cmd@gmail.com> Date: Wed, 2 Oct 2024 07:42:31 +0800 Subject: [PATCH] refactor: lint. --- .../src/ast_passes/peephole_fold_constants.rs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/crates/oxc_minifier/src/ast_passes/peephole_fold_constants.rs b/crates/oxc_minifier/src/ast_passes/peephole_fold_constants.rs index b668341607518f..929b1829e9bfdc 100644 --- a/crates/oxc_minifier/src/ast_passes/peephole_fold_constants.rs +++ b/crates/oxc_minifier/src/ast_passes/peephole_fold_constants.rs @@ -194,13 +194,13 @@ impl<'a> PeepholeFoldConstants { .then(|| { // Use `unwrap`, because we know it's a valid BigInt literal, which ends with 'n'. let value = BigInt::from_str(n.raw.as_str().strip_suffix('n').unwrap()); - value.ok().and_then(|value| { + value.ok().map(|value| { let value = !value; - Some(ctx.ast.expression_big_int_literal( + ctx.ast.expression_big_int_literal( SPAN, value.to_string() + "n", BigintBase::Decimal, - )) + ) }) }) .unwrap_or(None), @@ -232,12 +232,12 @@ impl<'a> PeepholeFoldConstants { value .ok() .and_then(|value| value.checked_sub(&BigInt::from(1))) - .and_then(|value| { - Some(ctx.ast.expression_big_int_literal( + .map(|value| { + ctx.ast.expression_big_int_literal( SPAN, value.neg().to_string() + "n", BigintBase::Decimal, - )) + ) }) }) .unwrap_or(None) @@ -266,7 +266,7 @@ impl<'a> PeepholeFoldConstants { } _ => None, }, - _ => None, + UnaryOperator::Delete => None } }