-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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 a saturating_cast between integers #23596
Comments
These kinds of additions to the language will also need to go through an RFC, and feature request stuff goes in the RFC repo these days. |
Actually, it's unclear that this needs to go through an RFC; it could be considered part of the work on the overflow RFC. But I think whether or not it is useful will depend on the final outcome re: the handling of casts. cc @pnkfelix |
cc #22020 |
Also, @mahkoh, is there some particular reason you included a sample implementation with a license that is not compatible with Rust? That is, was that unintentional, or did you want to be sure we would not use this sample code? If the latter, that's fine, but then it's not clear why you are putting it in the ticket. |
You can't use code posted without a license either because without a license it's proprietary. In this case I just copied the whole file including the header. |
@mahkoh so shall I take your comment as implicitly saying that we do not have your permission to use this code? In that case I might as well delete it, lest someone accidentally try to use it as the basis for an implementation. |
I obviously posted it because I want you to use it and the license header was there by accident. In the previous post I merely pointed out that @nikomatsakis's question was based on the wrong assumption that all code posted here without a license can automatically be used. No code that isn't explicitly posted with the correct licensing can be used automatically. |
@mahkoh Thank you for clarifying your intent. |
Similar to saturating_add but for casts. Untested implementation below.
The text was updated successfully, but these errors were encountered: