on master help sign in
Fix clippy warnings: collapse nested match and if statements
7a8d758iko
crates/htmlang-core/src/codegen.rs+1−5
@@ -3886,11 +3886,7 @@ fn auto_extract_repeats(
3886 while end < bytes.len() {
3886 while end < bytes.len() {
3887 match bytes[end] {
3887 match bytes[end] {
3888 b'(' => pdepth += 1,
3888 b'(' => pdepth += 1,
3889− b')' => {
3890− if pdepth > 0 {
3889+ b')' if pdepth > 0 => pdepth -= 1,
3891− pdepth -= 1;
3892− }
3893− }
3894 b';' | b'}' if pdepth == 0 => break,
3890 b';' | b'}' if pdepth == 0 => break,
3895 b'{' if pdepth == 0 => break,
3891 b'{' if pdepth == 0 => break,
3896 _ => {}
3892 _ => {}
crates/htmlang-core/src/parser.rs+13−19
@@ -4414,21 +4414,21 @@ fn parse_attr_list(
4414 }
4414 }
4415
4415
4416 // ...$name spread — expand define/attribute bundle
4416 // ...$name spread — expand define/attribute bundle
4417− if let Some(name) = part.strip_prefix("...$") {
4417+ if let Some(name) = part.strip_prefix("...$")
4418− if let Some(define_attrs) = ctx.defines.get(name) {
4418+ && let Some(define_attrs) = ctx.defines.get(name)
4419+ {
4419− ctx.used_defines.insert(name.to_string());
4420+ ctx.used_defines.insert(name.to_string());
4420− attrs.extend(define_attrs.clone());
4421+ attrs.extend(define_attrs.clone());
4421− continue;
4422+ continue;
4422− }
4423 }
4423 }
4424
4424
4425 // $define reference — expand attribute bundle
4425 // $define reference — expand attribute bundle
4426− if let Some(name) = part.strip_prefix('$') {
4426+ if let Some(name) = part.strip_prefix('$')
4427− if let Some(define_attrs) = ctx.defines.get(name) {
4427+ && let Some(define_attrs) = ctx.defines.get(name)
4428+ {
4428− ctx.used_defines.insert(name.to_string());
4429+ ctx.used_defines.insert(name.to_string());
4429− attrs.extend(define_attrs.clone());
4430+ attrs.extend(define_attrs.clone());
4430− continue;
4431+ continue;
4431− }
4432 }
4432 }
4433
4433
4434 // Substitute variables in value
4434 // Substitute variables in value
@@ -4837,13 +4837,7 @@ fn evaluate_arithmetic(input: &str) -> String {
4837 '+' => l + r,
4837 '+' => l + r,
4838 '-' => l - r,
4838 '-' => l - r,
4839 '*' => l * r,
4839 '*' => l * r,
4840− '/' => {
4841− if r != 0.0 {
4840+ '/' if r != 0.0 => l / r,
4842− l / r
4843− } else {
4844− return input.to_string();
4845− }
4846− }
4847 _ => return input.to_string(),
4841 _ => return input.to_string(),
4848 };
4842 };
4849 if result == result.floor() && result.abs() < i64::MAX as f64 {
4843 if result == result.floor() && result.abs() < i64::MAX as f64 {