Skip to content

Commit 66b32cf

Browse files
committed
Add a note saying that {u8,i8}::from_{be,le,ne}_bytes is useless
1 parent f6cb952 commit 66b32cf

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 technically useless on `u8`. Byte order does not
85+
exist as a concept for byte-sized integers. This function is only provided in
86+
symmetry with larger integer types.
87+
88+
"
89+
};
90+
}
91+
92+
macro_rules! i8_xe_bytes_doc {
93+
() => {
94+
"
95+
96+
**Note**: This function is technically useless on `i8`. Byte order does not
97+
exist as a concept for byte-sized integers. This function is only provided in
98+
symmetry with larger integer types. You can cast from and two `u8` using `as
99+
i8` and `as 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)