Fix code for rustfmt and clippy

This commit is contained in:
johan.park
2019-08-16 16:33:29 +09:00
parent 7b5f574847
commit fddbbc701f

View File

@@ -237,13 +237,12 @@ fn math_gcd(a: PyIntRef, b: PyIntRef, vm: &VirtualMachine) -> PyResult {
fn math_factorial(vm: &VirtualMachine, args: PyFuncArgs) -> PyResult {
arg_check!(vm, args, required = [(value, None)]);
let value = objint::get_value(value);
if value < &BigInt::zero() {
return Err(vm.new_value_error(format!("factorial() not defined for negative values")))
} else if value <= &BigInt::one() {
return Ok(vm.ctx.new_int(BigInt::from(1u64)))
if *value < BigInt::zero() {
return Err(vm.new_value_error("factorial() not defined for negative values".to_string()));
} else if *value <= BigInt::one() {
return Ok(vm.ctx.new_int(BigInt::from(1u64)));
}
let ret: BigInt =
num_iter::range_inclusive(BigInt::from(1u64), BigInt::from(value.clone())).product();
let ret: BigInt = num_iter::range_inclusive(BigInt::from(1u64), value.clone()).product();
Ok(vm.ctx.new_int(ret))
}