-
Notifications
You must be signed in to change notification settings - Fork 13.2k
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
Deprecate free-standing endian conversions in favor of methods on Int. Merge Bitwise into Int and add more bit operations. #14917
Conversation
Note that this is explicitly moving some functions from I'm personally a little sad to see this expressed in yet another trait, and I'm not a huge fan of |
|
Ok, I removed the deprecations. |
Do we actually want to be "stuck" with the old |
I'm not necessarily saying that we're stuck with |
The `Bitwise::swap_bytes` method was also moved into the `ByteOrder` trait. This was because it works on the byte level rather than the bit level.
Ok, me and @alexcrichton discussed this, and decided it was probably better just to merge the bit and bytewise stuff into the |
/// | ||
/// # Example | ||
/// | ||
/// ```rust | ||
/// use std::num::Bitwise; | ||
/// static N: u8 = 0b01001100; |
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.
Why change these to statics?
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.
Hm, seemed more clear. I can change them back though.
In general, this seems good to me. I still prefer |
Sure thing. |
This reduces the complexity of the trait hierarchy.
…d mark them as deprecated
@alexcrichton de-staticised |
cc me |
LGTM. I also prefer the brevity of |
Speaking to @aturon over lunch, he also prefers the shorter names. I will alter the patch to use the shorter names them. |
Any more feedback on this? |
The consensus on rust-lang#14917 was that the proposed names were too long.
We chatted on IRC. r=me if you remove the new {set,get,flip,clear}_bit functions. |
The consensus on rust-lang#14917 was that the proposed names were too long.
The free-standing endian conversion functions have been deprecated in favour of a group of conversion functions grouped together in the
Int
trait:mem::from_be*
->Int::from_be
mem::from_le*
->Int::from_le
mem::to_be*
->Int::to_be
mem::to_le*
->Int::to_le
The
Bitwise
trait was also merged withInt
. This further simplifies the trait hierarchy.The
get_bit
,set_bit
,clear_bit
, andflip_bit
methods were added to theInt
trait.[breaking-change]
core::num::Bitwise::swap_bytes
was moved tocore::num::Int
The free-standing endian conversion functions in
core::mem
have been deprecated and had their#[stable]
attributes removed.