Skip to content

Commit 8bd6718

Browse files
authored
fix: resolve clippy warnings breaking CI on main (#46)
- Replace single-arm match with if-let for modulo-by-zero check (clippy::single_match) - Remove redundant closure in join() (clippy::redundant_closure) - Replace 3.14 test values with 2.72 to avoid clippy::approx_constant (PI detection) Fixes CI failure introduced by #45.
1 parent 5e489fc commit 8bd6718

File tree

2 files changed

+7
-10
lines changed

2 files changed

+7
-10
lines changed

src/mapping/eval.rs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -222,11 +222,8 @@ fn eval_binary_op(left: &Value, op: BinOp, right: &Value) -> error::Result<Value
222222
eval_arithmetic(left, right, |a, b| a / b, |a, b| a / b)
223223
}
224224
BinOp::Mod => {
225-
match right {
226-
Value::Int(0) => {
227-
return Err(error::MorphError::mapping("modulo by zero"));
228-
}
229-
_ => {}
225+
if let Value::Int(0) = right {
226+
return Err(error::MorphError::mapping("modulo by zero"));
230227
}
231228
eval_arithmetic(left, right, |a, b| a % b, |a, b| a % b)
232229
}

src/mapping/functions.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ fn fn_join(args: &[Value]) -> error::Result<Value> {
207207
}
208208
};
209209
let sep = to_str(&args[1]);
210-
let parts: Vec<String> = arr.iter().map(|v| to_str(v)).collect();
210+
let parts: Vec<String> = arr.iter().map(to_str).collect();
211211
Ok(Value::String(parts.join(&sep)))
212212
}
213213

@@ -634,8 +634,8 @@ mod tests {
634634
#[test]
635635
fn test_to_float() {
636636
assert_eq!(
637-
call_function("to_float", &[Value::String("3.14".into())]).unwrap(),
638-
Value::Float(3.14)
637+
call_function("to_float", &[Value::String("2.72".into())]).unwrap(),
638+
Value::Float(2.72)
639639
);
640640
assert_eq!(
641641
call_function("to_float", &[Value::Int(42)]).unwrap(),
@@ -694,8 +694,8 @@ mod tests {
694694
Value::Int(5)
695695
);
696696
assert_eq!(
697-
call_function("abs", &[Value::Float(-3.14)]).unwrap(),
698-
Value::Float(3.14)
697+
call_function("abs", &[Value::Float(-2.72)]).unwrap(),
698+
Value::Float(2.72)
699699
);
700700
}
701701

0 commit comments

Comments
 (0)