Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(clippy): fix clippy warnings #103

Merged
merged 1 commit into from
Feb 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading