Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit dccce2d

Browse files
authoredDec 11, 2024
Unrolled build for rust-lang#134079
Rollup merge of rust-lang#134079 - tbu-:pr_doc_x8_to_from_xe_bytes, r=jhpratt Add a note saying that `{u8,i8}::from_{be,le,ne}_bytes` is meaningless
2 parents 5a6036a + e37d7c0 commit dccce2d

File tree

1 file changed

+29
-4
lines changed

1 file changed

+29
-4
lines changed
 

‎library/core/src/num/mod.rs

+29-4
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,31 @@ pub use saturating::Saturating;
7777
#[stable(feature = "rust1", since = "1.0.0")]
7878
pub use wrapping::Wrapping;
7979

80+
macro_rules! u8_xe_bytes_doc {
81+
() => {
82+
"
83+
84+
**Note**: This function is meaningless on `u8`. Byte order does not exist as a
85+
concept for byte-sized integers. This function is only provided in symmetry
86+
with larger integer types.
87+
88+
"
89+
};
90+
}
91+
92+
macro_rules! i8_xe_bytes_doc {
93+
() => {
94+
"
95+
96+
**Note**: This function is meaningless on `i8`. Byte order does not exist as a
97+
concept for byte-sized integers. This function is only provided in symmetry
98+
with larger integer types. You can cast from and to `u8` using `as i8` and `as
99+
u8`.
100+
101+
"
102+
};
103+
}
104+
80105
macro_rules! usize_isize_to_xe_bytes_doc {
81106
() => {
82107
"
@@ -348,8 +373,8 @@ impl i8 {
348373
reversed = "0x48",
349374
le_bytes = "[0x12]",
350375
be_bytes = "[0x12]",
351-
to_xe_bytes_doc = "",
352-
from_xe_bytes_doc = "",
376+
to_xe_bytes_doc = i8_xe_bytes_doc!(),
377+
from_xe_bytes_doc = i8_xe_bytes_doc!(),
353378
bound_condition = "",
354379
}
355380
midpoint_impl! { i8, i16, signed }
@@ -547,8 +572,8 @@ impl u8 {
547572
reversed = "0x48",
548573
le_bytes = "[0x12]",
549574
be_bytes = "[0x12]",
550-
to_xe_bytes_doc = "",
551-
from_xe_bytes_doc = "",
575+
to_xe_bytes_doc = u8_xe_bytes_doc!(),
576+
from_xe_bytes_doc = u8_xe_bytes_doc!(),
552577
bound_condition = "",
553578
}
554579
widening_impl! { u8, u16, 8, unsigned }

0 commit comments

Comments
 (0)
Failed to load comments.