Simplify std::num::Primitive trait definition #11622
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
As part of #10387, this removes the
Primitive::{bits, bytes, is_signed}
methods and removes the trait's operator trait constraints for the reasons outlined below:Primitive::{bits, bytes}
associated functions were originally added to reflect the existingBITS
andBYTES
statics included in the numeric modules. These statics are only exist as a workaround for Rust's lack of CTFE, and should be deprecated in the future in favor of using thestd::mem::size_of
function (see Implement compile time function evaluation (CTFE) #11621).Primitive::is_signed
seems to be of little utility and does not seem to be used anywhere in the Rust compiler or libraries. It is also rather ugly to call due to theOption<Self>
workaround for Ability to specify self parameter in static method call #8888.Num
trait.