mirror of
https://github.com/RustPython/RustPython.git
synced 2026-06-09 22:49:57 +09:00
Fix code for rustfmt and clippy
This commit is contained in:
@@ -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))
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user