Skip to content

Commit

Permalink
chore(clippy): fix clippy warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
dnsl48 committed Feb 11, 2024
1 parent bdced7b commit d12dce3
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 45 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -68,4 +68,4 @@ jobs:
uses: actions-rs/cargo@v1
with:
command: clippy
args: --all-features -- -D warnings
args: --all-features -- -D warnings -A deprecated
42 changes: 18 additions & 24 deletions src/decimal/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -407,38 +407,32 @@ where

let mut precision: usize = 0;
loop {
s_state = match division::divide_rem_resume(
s_state.take().unwrap(),
|s, d| {
s_state = if let Ok(s) =
division::divide_rem_resume(s_state.take().unwrap(), |s, d| {
s_digit = d;
Ok(Err(s))
},
) {
Ok(s) => {
if s.remainder.is_zero() {
None
} else {
Some(s)
}
}) {
if s.remainder.is_zero() {
None
} else {
Some(s)
}
Err(_) => return false,
} else {
return false;
};

o_state = match division::divide_rem_resume(
o_state.take().unwrap(),
|s, d| {
o_state = if let Ok(s) =
division::divide_rem_resume(o_state.take().unwrap(), |s, d| {
o_digit = d;
Ok(Err(s))
},
) {
Ok(s) => {
if s.remainder.is_zero() {
None
} else {
Some(s)
}
}) {
if s.remainder.is_zero() {
None
} else {
Some(s)
}
Err(_) => return false,
} else {
return false;
};

if s_digit != o_digit {
Expand Down
45 changes: 26 additions & 19 deletions src/fraction/display.rs
Original file line number Diff line number Diff line change
Expand Up @@ -299,39 +299,46 @@ where
let mut length = 0;

if let Some(precision) = format.precision() {
match division::divide_to_callback(
let callback = |digit| {
length += 1;
division::write_digit(buffer, digit)
};

if division::divide_to_callback(
numer,
denom,
*precision,
format.alternate(),
|digit| {
length += 1;
division::write_digit(buffer, digit)
},
) {
Ok(_) => Ok(()),
Err(_) => Err(fmt::Error),
}?;
callback,
)
.is_err()
{
return Err(fmt::Error);
}
} else {
match division::divide_to_callback(numer, T::one(), 0, false, |digit| {
let callback = |digit| {
length += 1;
division::write_digit(buffer, digit)
}) {
Ok(_) => Ok(()),
Err(_) => Err(fmt::Error),
}?;
};

if division::divide_to_callback(numer, T::one(), 0, false, callback).is_err() {
return Err(fmt::Error);
}

if !ratio.numer().is_zero() && !ratio.denom().is_one() {
length += 1;
buffer.write_char('/')?;

match division::divide_to_callback(denom, T::one(), 0, false, |digit| {
let callback = |digit| {
length += 1;
division::write_digit(buffer, digit)
}) {
Ok(_) => Ok(()),
Err(_) => Err(fmt::Error),
}?;
};

if division::divide_to_callback(denom, T::one(), 0, false, callback)
.is_err()
{
return Err(fmt::Error);
};
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/fraction/unicode_str_io.rs
Original file line number Diff line number Diff line change
Expand Up @@ -551,7 +551,7 @@ mod tests {
#[test]
fn test_from_fail() {
// TODO: "nanBOGUS" and "∞BOGUS" will parse.
// Either make that everything with BOGUS
// Either make that everything with BOGUS
// after will parse, or make ^those fail.
let test_vec = vec![
"asdf",
Expand Down

0 comments on commit d12dce3

Please sign in to comment.