Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 2 additions & 5 deletions src/mapping/eval.rs
Original file line number Diff line number Diff line change
Expand Up @@ -222,11 +222,8 @@ fn eval_binary_op(left: &Value, op: BinOp, right: &Value) -> error::Result<Value
eval_arithmetic(left, right, |a, b| a / b, |a, b| a / b)
}
BinOp::Mod => {
match right {
Value::Int(0) => {
return Err(error::MorphError::mapping("modulo by zero"));
}
_ => {}
if let Value::Int(0) = right {
return Err(error::MorphError::mapping("modulo by zero"));
}
eval_arithmetic(left, right, |a, b| a % b, |a, b| a % b)
}
Expand Down
10 changes: 5 additions & 5 deletions src/mapping/functions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ fn fn_join(args: &[Value]) -> error::Result<Value> {
}
};
let sep = to_str(&args[1]);
let parts: Vec<String> = arr.iter().map(|v| to_str(v)).collect();
let parts: Vec<String> = arr.iter().map(to_str).collect();
Ok(Value::String(parts.join(&sep)))
}

Expand Down Expand Up @@ -634,8 +634,8 @@ mod tests {
#[test]
fn test_to_float() {
assert_eq!(
call_function("to_float", &[Value::String("3.14".into())]).unwrap(),
Value::Float(3.14)
call_function("to_float", &[Value::String("2.72".into())]).unwrap(),
Value::Float(2.72)
);
assert_eq!(
call_function("to_float", &[Value::Int(42)]).unwrap(),
Expand Down Expand Up @@ -694,8 +694,8 @@ mod tests {
Value::Int(5)
);
assert_eq!(
call_function("abs", &[Value::Float(-3.14)]).unwrap(),
Value::Float(3.14)
call_function("abs", &[Value::Float(-2.72)]).unwrap(),
Value::Float(2.72)
);
}

Expand Down