From fddbbc701f640ba91b3ff5b5beb27315a1451628 Mon Sep 17 00:00:00 2001 From: "johan.park" Date: Fri, 16 Aug 2019 16:33:29 +0900 Subject: [PATCH] Fix code for rustfmt and clippy --- vm/src/stdlib/math.rs | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/vm/src/stdlib/math.rs b/vm/src/stdlib/math.rs index 9be54c90e..a4ccd1fef 100644 --- a/vm/src/stdlib/math.rs +++ b/vm/src/stdlib/math.rs @@ -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)) }