-
Notifications
You must be signed in to change notification settings - Fork 135
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 saturating_mul() and refactor Saturating into subtraits. Fixes #40. #165
Conversation
Also, it occurred to me that there is no harm in making a backwards compatible compound Saturating trait from |
Breaking changes are definitely a concern, and unfortunately this idea doesn't solve it. That would be fine for users of the trait, but it still breaks any implementors of the trait. Since the trait is not sealed, 3rd parties can and do implement it as well, e.g. We can instead deprecate |
Good point! Sorry I did not think that through entirely. I restored the original Let me know if there is a better way to go about deprecating Thank you for looking at my pull request. |
src/ops/saturating.rs
Outdated
} | ||
}; | ||
($trait_name:ident, $method:ident, $t:ty, $rhs:ty) => { | ||
impl $trait_name<$rhs> for $t { |
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 this second macro pattern actually used? I think not, because your new traits don't have a generic RHS.
bors r+ |
Hi all,
Taking the suggestion from #40, this pull request breaks out the saturating trait into three separate SaturatingAdd, SaturatingSub and SaturatingMul traits, borrowing the idea from Checked* and Wrapping*. In terms of native ops, SaturatingNeg would be an option on signed types once the saturating_neg() API is stable on signed integer primitives.
I know there is concern about breaking changes, so I was thinking that I could add a wrapping Saturating trait for backwards compatibility that retains the original functionality:
This is not included in the current version, but I would be happy to add.
-Tom ([email protected])