Skip to content

Commit

Permalink
Rollup merge of rust-lang#75211 - lzutao:native-endian-notes, r=lcnr
Browse files Browse the repository at this point in the history
Note about endianness of returned value of {integer}::from_be_bytes and friends

[`u32::from_be`](https://doc.rust-lang.org/nightly/src/core/num/mod.rs.html#2883-2892) documents about endianness of returned value.

I was confused by endianness of `from_be_bytes` in rust-lang#75086 .
  • Loading branch information
JohnTitor authored Aug 6, 2020
2 parents 444a32e + eff7d56 commit 15dd907
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions library/core/src/num/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4383,8 +4383,8 @@ assert_eq!(
}

doc_comment! {
concat!("Create an integer value from its representation as a byte array in
big endian.
concat!("Create a native endian integer value from its representation
as a byte array in big endian.
",
$from_xe_bytes_doc,
"
Expand Down Expand Up @@ -4416,8 +4416,8 @@ fn read_be_", stringify!($SelfT), "(input: &mut &[u8]) -> ", stringify!($SelfT),

doc_comment! {
concat!("
Create an integer value from its representation as a byte array in
little endian.
Create a native endian integer value from its representation
as a byte array in little endian.
",
$from_xe_bytes_doc,
"
Expand Down Expand Up @@ -4448,8 +4448,8 @@ fn read_le_", stringify!($SelfT), "(input: &mut &[u8]) -> ", stringify!($SelfT),
}

doc_comment! {
concat!("Create an integer value from its memory representation as a byte
array in native endianness.
concat!("Create a native endian integer value from its memory representation
as a byte array in native endianness.
As the target platform's native endianness is used, portable code
likely wants to use [`from_be_bytes`] or [`from_le_bytes`], as
Expand Down

0 comments on commit 15dd907

Please sign in to comment.