Skip to content
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

Merged
merged 2 commits into from
Aug 17, 2018

Conversation

SimonSapin
Copy link
Contributor

Same as #51919 did for signed integers.

Tracking issue: #52963

@rust-highfive
Copy link
Collaborator

r? @shepmaster

(rust_highfive has picked a reviewer for you, use r? to override)

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Aug 14, 2018
@tbu-
Copy link
Contributor

tbu- commented Aug 14, 2018

Sorry, don't know how I missed that.

/// ```
/// #![feature(int_to_from_bytes)]
///
/// let bytes = 0x12345678i32.to_be_bytes();
Copy link
Member

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]);

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ditto below.

Copy link
Contributor Author

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]);
Copy link
Member

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?

Copy link
Contributor

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.

@shepmaster
Copy link
Member

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)

@SimonSapin
Copy link
Contributor Author

@bors r=shepmaster

@bors
Copy link
Contributor

bors commented Aug 17, 2018

📌 Commit f5556a6 has been approved by shepmaster

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Aug 17, 2018
frewsxcv added a commit to frewsxcv/rust that referenced this pull request Aug 17, 2018
`{to,from}_{ne,le,be}_bytes` for unsigned integer types

Same as rust-lang#51919 did for signed integers.

Tracking issue: rust-lang#52963
bors added a commit that referenced this pull request Aug 17, 2018
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
@bors bors merged commit f5556a6 into rust-lang:master Aug 17, 2018
@SimonSapin SimonSapin deleted the int-bytes branch November 28, 2019 12:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants