refactor: fix compiler warnings
This commit is contained in:
parent
91dd6fcc8b
commit
bb167d4a9a
@ -109,9 +109,9 @@ fn pidigits(n: isize, out: &mut io::Write) -> io::Result<()> {
|
||||
}
|
||||
}
|
||||
|
||||
try!(write!(out, "{}", d));
|
||||
write!(out, "{}", d)?;
|
||||
if i % 10 == 0 {
|
||||
try!(write!(out, "\t:{}\n", i));
|
||||
write!(out, "\t:{}\n", i)?;
|
||||
}
|
||||
|
||||
context.eliminate_digit(d);
|
||||
@ -120,9 +120,9 @@ fn pidigits(n: isize, out: &mut io::Write) -> io::Result<()> {
|
||||
let m = n % 10;
|
||||
if m != 0 {
|
||||
for _ in m..10 {
|
||||
try!(write!(out, " "));
|
||||
write!(out, " ")?;
|
||||
}
|
||||
try!(write!(out, "\t:{}\n", n));
|
||||
write!(out, "\t:{}\n", n)?;
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
@ -1,8 +1,8 @@
|
||||
#![allow(clippy::suspicious_arithmetic_impl)]
|
||||
#[allow(deprecated, unused_imports)]
|
||||
use alloc::borrow::Cow;
|
||||
use alloc::vec::Vec;
|
||||
use alloc::string::String;
|
||||
use alloc::vec::Vec;
|
||||
use core::cmp::Ordering::{self, Equal, Greater, Less};
|
||||
use core::default::Default;
|
||||
use core::hash::{Hash, Hasher};
|
||||
@ -703,7 +703,7 @@ impl Num for BigInt {
|
||||
} else {
|
||||
Plus
|
||||
};
|
||||
let bu = try!(BigUint::from_str_radix(s, radix));
|
||||
let bu = BigUint::from_str_radix(s, radix)?;
|
||||
Ok(BigInt::from_biguint(sign, bu))
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
#[allow(deprecated, unused_imports)]
|
||||
use alloc::borrow::Cow;
|
||||
use alloc::vec::Vec;
|
||||
use alloc::string::String;
|
||||
use alloc::vec::Vec;
|
||||
use core::cmp::Ordering::{self, Equal, Greater, Less};
|
||||
use core::default::Default;
|
||||
use core::hash::{Hash, Hasher};
|
||||
@ -13,7 +13,7 @@ use core::ops::{
|
||||
use core::str::{self, FromStr};
|
||||
use core::{cmp, fmt, mem};
|
||||
use core::{f32, f64};
|
||||
use core::{u64, u32, u8};
|
||||
use core::{u32, u64, u8};
|
||||
|
||||
#[cfg(not(feature = "std"))]
|
||||
use libm::F64Ext;
|
||||
@ -25,11 +25,11 @@ use serde;
|
||||
use zeroize::Zeroize;
|
||||
|
||||
use integer::{Integer, Roots};
|
||||
use num_traits::{
|
||||
CheckedAdd, CheckedDiv, CheckedMul, CheckedSub, FromPrimitive, Num, One, Pow,
|
||||
ToPrimitive, Unsigned, Zero,
|
||||
};
|
||||
use num_traits::float::FloatCore;
|
||||
use num_traits::{
|
||||
CheckedAdd, CheckedDiv, CheckedMul, CheckedSub, FromPrimitive, Num, One, Pow, ToPrimitive,
|
||||
Unsigned, Zero,
|
||||
};
|
||||
|
||||
use BigInt;
|
||||
|
||||
@ -44,7 +44,7 @@ use self::monty::monty_modpow;
|
||||
use super::VEC_SIZE;
|
||||
use crate::algorithms::{__add2, __sub2rev, add2, sub2, sub2rev};
|
||||
use crate::algorithms::{biguint_shl, biguint_shr};
|
||||
use crate::algorithms::{cmp_slice, fls, ilog2, idiv_ceil};
|
||||
use crate::algorithms::{cmp_slice, fls, idiv_ceil, ilog2};
|
||||
use crate::algorithms::{div_rem, div_rem_digit, mac_with_carry, mul3, scalar_mul};
|
||||
use crate::algorithms::{extended_gcd, mod_inverse};
|
||||
use crate::traits::{ExtendedGcd, ModInverse};
|
||||
@ -260,9 +260,9 @@ impl Num for BigUint {
|
||||
let mut v = Vec::with_capacity(s.len());
|
||||
for b in s.bytes() {
|
||||
let d = match b {
|
||||
b'0'...b'9' => b - b'0',
|
||||
b'a'...b'z' => b - b'a' + 10,
|
||||
b'A'...b'Z' => b - b'A' + 10,
|
||||
b'0'..=b'9' => b - b'0',
|
||||
b'a'..=b'z' => b - b'a' + 10,
|
||||
b'A'..=b'Z' => b - b'A' + 10,
|
||||
b'_' => continue,
|
||||
_ => u8::MAX,
|
||||
};
|
||||
@ -2542,7 +2542,7 @@ impl<'de> serde::Deserialize<'de> for BigUint {
|
||||
where
|
||||
D: serde::Deserializer<'de>,
|
||||
{
|
||||
let data: Vec<u32> = try!(Vec::deserialize(deserializer));
|
||||
let data: Vec<u32> = Vec::deserialize(deserializer)?;
|
||||
Ok(BigUint::new(data))
|
||||
}
|
||||
}
|
||||
|
@ -20,8 +20,8 @@ use std::{i16, i32, i64, i8, isize};
|
||||
use std::{u16, u32, u64, u8, usize};
|
||||
|
||||
use num_integer::Integer;
|
||||
use num_traits::{FromPrimitive, Num, One, Pow, Signed, ToPrimitive, Zero};
|
||||
use num_traits::float::FloatCore;
|
||||
use num_traits::{FromPrimitive, Num, One, Pow, Signed, ToPrimitive, Zero};
|
||||
|
||||
mod consts;
|
||||
use consts::*;
|
||||
@ -677,9 +677,9 @@ fn test_add() {
|
||||
fn test_add_mut() {
|
||||
for elm in SUM_TRIPLES.iter() {
|
||||
let (a_vec, b_vec, c_vec) = *elm;
|
||||
let mut a = BigInt::from_slice(Plus, a_vec);
|
||||
let mut b = BigInt::from_slice(Plus, b_vec);
|
||||
let mut c = BigInt::from_slice(Plus, c_vec);
|
||||
let a = BigInt::from_slice(Plus, a_vec);
|
||||
let b = BigInt::from_slice(Plus, b_vec);
|
||||
let c = BigInt::from_slice(Plus, c_vec);
|
||||
let (na, nb, nc) = (-&a, -&b, -&c);
|
||||
|
||||
assert_op!(a + b == c);
|
||||
@ -1120,7 +1120,6 @@ fn test_negative_shr() {
|
||||
#[test]
|
||||
#[cfg(feature = "rand")]
|
||||
fn test_random_shr() {
|
||||
|
||||
#[cfg(feature = "std")]
|
||||
fn thread_rng() -> impl rand::Rng {
|
||||
rand::thread_rng()
|
||||
@ -1132,8 +1131,8 @@ fn test_random_shr() {
|
||||
rand::rngs::StdRng::seed_from_u64(4)
|
||||
}
|
||||
|
||||
use rand::Rng;
|
||||
use rand::distributions::Standard;
|
||||
use rand::Rng;
|
||||
|
||||
let mut rng = thread_rng();
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user