-
Notifications
You must be signed in to change notification settings - Fork 12.1k
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
Saturating math #8323
Saturating math #8323
Conversation
@@ -466,6 +466,56 @@ impl<T: Zero> Zero for ~T { | |||
fn is_zero(&self) -> bool { (**self).is_zero() } | |||
} | |||
|
|||
/// Saturating math operations |
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.
It seems odd to use static methods here - is there a reason not to use normal methods?
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.
I didn't like the idea of saying a.saturating_add(b)
. Just seemed odd to me.
Saturating is an implementation of saturating math operations (at the moment just add and sub) for integral types.
Replace hand-rolled saturation math with calls to Saturating. Fix one impl that didn't use saturating math.
r? @thestinger |
Implement saturating math in `std::num::Saturating` and use it for `Iterator` impls
This relates to #4819 |
…xFrednet warn if we find multiple clippy configs Fixes rust-lang#8323 --- *Please write a short comment explaining your change (or "none" for internal only changes)* changelog: warn if we find multiple clippy configs
Implement saturating math in
std::num::Saturating
and use it forIterator
impls