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

Use Saturating / UniqueSaturatedFrom / UniqueSaturatedInto to simplify code #42

Closed
xlc opened this issue Dec 18, 2019 · 1 comment
Closed

Comments

@xlc
Copy link
Member

xlc commented Dec 18, 2019

Review the code and do following changes:

  • Change x.unwrap_or(0.into)
    • To x.unwrap_or_default()
  • Change let x = TryInto::<u128>::try_into(x).unwrap_or(Bounded::max_value());
    • To let x: u128 = x.unique_saturated_into();
  • Change x.checked_mul(&y).unwrap_or(Bounded::max_value())
    • To x. saturating_mul(y)
  • Same for checked_div / checked_add / checked_sub / checked_mul_int

Relates: #41

@xlc
Copy link
Member Author

xlc commented Dec 23, 2019

Fixed by #43

@xlc xlc closed this as completed Dec 23, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant