Skip to content

Commit

Permalink
fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
ognevny committed Feb 23, 2024
1 parent 81a2505 commit 98e678d
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 18 deletions.
6 changes: 1 addition & 5 deletions src/algorithm/prime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -141,11 +141,7 @@ pub fn sqrtest(num: isize) -> Result<PrimeStatus, PrimeStatusError> {
// FIXME: https://github.com/rust-lang/rust/issues/116226
// let sqrt_res = num.isqrt().unsigned_abs()
let sqrt_res = (num as f64).sqrt().ceil() as usize;
if (3..=sqrt_res)
.into_par_iter()
.find_any(|&i| num.unsigned_abs() % i == 0)
.is_some()
{
if (3..=sqrt_res).into_par_iter().find_any(|&i| num.unsigned_abs() % i == 0).is_some() {
Ok(PrimeStatus::Composite)
} else {
Ok(PrimeStatus::Prime)
Expand Down
24 changes: 11 additions & 13 deletions src/num/radix.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
//! Structs for radix numbers (String nums and int nums). All numbers are unsigned integers.
use {
super::methods::Num,
std::{cmp::Ordering, num::ParseIntError, ops, str::FromStr},
thiserror::Error,
super::methods::Num,
};

/// Reference to slice of chars from '0' to 'Z' (maximum base is 36).
Expand Down Expand Up @@ -925,18 +925,16 @@ impl Radix {
pub fn from_radix(number: usize, base: u8) -> Result<Self, RadixError> {
match base {
0 | 1 | 11.. => Err(RadixError::BaseError(10, base)),
_ => {
RADIX
.iter()
.take(10)
.skip(base.into())
.find_map(|i| {
number
.has_digit(i.to_string().parse().unwrap())
.then_some(Err(RadixError::NumberError(*i, base)))
})
.map_or(Ok(Self { number, base }), |err| err)
},
_ => RADIX
.iter()
.take(10)
.skip(base.into())
.find_map(|i| {
number
.has_digit(i.to_string().parse().unwrap())
.then_some(Err(RadixError::NumberError(*i, base)))
})
.map_or(Ok(Self { number, base }), |err| err),
}
}

Expand Down

0 comments on commit 98e678d

Please sign in to comment.