-
Notifications
You must be signed in to change notification settings - Fork 8
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
Add recoverable errors #30
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will review later.
src/.DS_Store
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You have to git rm --cached .DS_Store
since it's already added to git indexing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok
assert!(Fraction::new(5, 12) > Fraction::new(4, 12)); | ||
} | ||
|
||
#[test] | ||
fn test_multiply() { | ||
assert_eq!( | ||
Fraction::new(1, 10) * Fraction::new(4, 12), | ||
(Fraction::new(1, 10) * Fraction::new(4, 12)), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Adding redundant parenthesis only increases the cost to review.
src/entities/fractions/fraction.rs
Outdated
assert_eq!(f.clone().as_fraction(), f.clone()); | ||
assert_ne!(&f.clone() as *const _, &f.clone().as_fraction() as *const _); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is no need to make clones if the code was working as intended.
src/entities/fractions/percent.rs
Outdated
(self.as_fraction() * ONE_HUNDRED.clone()) | ||
.to_significant(significant_digits, rounding) | ||
.unwrap() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The base method returns Result<String, Error>
. Why is it unwrapped here?
src/entities/fractions/percent.rs
Outdated
} | ||
|
||
/// Converts the Percent to a string with a fixed number of decimal places and rounding strategy | ||
pub fn to_fixed(&self, decimal_places: u8, rounding: Rounding) -> String { | ||
// Convert the Percent to a simple Fraction, multiply by 100, and then call to_fixed on the result | ||
// Convert the Percent to a simple Fraction, multiply by 100, and then call to_fixed on the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// Convert the Percent to a simple Fraction, multiply by 100, and then call to_fixed on the | |
// Convert the Percent to a simple Fraction, multiply by 100, and then call to_fixed on the result |
Please don't accidentally delete comments.
@@ -39,47 +41,47 @@ mod tests { | |||
#[test] | |||
fn test_add() { | |||
assert_eq!( | |||
Percent::new(1, 100) + Percent::new(2, 100), | |||
(Percent::new(1, 100) + Percent::new(2, 100)), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These are just unnecessary diffs.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is there a way clippy can discover this
src/entities/fractions/price.rs
Outdated
return Err(Error::NotEqual("the comparison are not equal".to_owned())); | ||
} | ||
|
||
let fraction = (self.as_fraction() * other.as_fraction()).clone(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A clone is unnecessary.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yep
fix issue #26
bump to 0.9.0
introduce recoverable errors