-
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
{to,from}_{ne,le,be}_bytes
for unsigned integer types
#53358
Conversation
Same as rust-lang#51919 did for signed integers. Tracking issue: rust-lang#52963
r? @shepmaster (rust_highfive has picked a reviewer for you, use r? to override) |
Sorry, don't know how I missed that. |
src/libcore/num/mod.rs
Outdated
/// ``` | ||
/// #![feature(int_to_from_bytes)] | ||
/// | ||
/// let bytes = 0x12345678i32.to_be_bytes(); |
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 like the example in the other code that gratuitously uses underscores to make this easy to follow:
let bytes = 0x12_34_56_78_i32.to_be_bytes();
assert_eq!(bytes, [0x12, 0x34, 0x56, 0x78]);
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.
Ditto below.
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.
Done.
/// #![feature(int_to_from_bytes)] | ||
/// | ||
/// let bytes = i32::min_value().to_be().to_ne_bytes(); | ||
/// assert_eq!(bytes, [0x80, 0, 0, 0]); |
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.
Will this pass on all of the testbed machines?
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.
Yes, due to the to_be()
in there.
Seems fine to me and it's all unstable anyway. r=me after adjusting the tests to split up the long literals (or you can ignore that and r=me anyway, if you disagree) |
@bors r=shepmaster |
📌 Commit f5556a6 has been approved by |
`{to,from}_{ne,le,be}_bytes` for unsigned integer types Same as rust-lang#51919 did for signed integers. Tracking issue: rust-lang#52963
Rollup of 11 pull requests Successful merges: - #52858 (Implement Iterator::size_hint for Elaborator.) - #53321 (Fix usage of `wasm_target_feature`) - #53326 ([nll] add regression test for issue #27868) - #53347 (rustc_resolve: don't allow paths starting with `::crate`.) - #53349 ([nll] add tests for #48697 and #30104) - #53357 (Pretty print btreemap for GDB) - #53358 (`{to,from}_{ne,le,be}_bytes` for unsigned integer types) - #53406 (Do not suggest conversion method that is already there) - #53407 (make more ported compile fail tests more robust w.r.t. NLL) - #53413 (Warn that `#![feature(rust_2018_preview)]` is implied when the edition is set to Rust 2018.) - #53434 (wasm: Remove --strip-debug argument to LLD) Failed merges: r? @ghost
Same as #51919 did for signed integers.
Tracking issue: #52963