diff options
| author | Tobias Bucher <tobiasbucher5991@gmail.com> | 2024-12-09 14:48:13 +0100 |
|---|---|---|
| committer | Tobias Bucher <tobiasbucher5991@gmail.com> | 2024-12-11 02:18:17 +0100 |
| commit | e37d7c0f1517be79e81264719867495fd7aa767a (patch) | |
| tree | 9aa1acbdeeed5f9fa5883bc6c448a9a5119215fb | |
| parent | 33c245b9e98bc91e18ea1c5033824f4c6f92766f (diff) | |
| download | rust-e37d7c0f1517be79e81264719867495fd7aa767a.tar.gz rust-e37d7c0f1517be79e81264719867495fd7aa767a.zip | |
Add a note saying that `{u8,i8}::from_{be,le,ne}_bytes` is meaningless
| -rw-r--r-- | library/core/src/num/mod.rs | 33 |
1 files changed, 29 insertions, 4 deletions
diff --git a/library/core/src/num/mod.rs b/library/core/src/num/mod.rs index e36f20fd576..357a85ae843 100644 --- a/library/core/src/num/mod.rs +++ b/library/core/src/num/mod.rs @@ -77,6 +77,31 @@ pub use saturating::Saturating; #[stable(feature = "rust1", since = "1.0.0")] pub use wrapping::Wrapping; +macro_rules! u8_xe_bytes_doc { + () => { + " + +**Note**: This function is meaningless on `u8`. Byte order does not exist as a +concept for byte-sized integers. This function is only provided in symmetry +with larger integer types. + +" + }; +} + +macro_rules! i8_xe_bytes_doc { + () => { + " + +**Note**: This function is meaningless on `i8`. Byte order does not exist as a +concept for byte-sized integers. This function is only provided in symmetry +with larger integer types. You can cast from and to `u8` using `as i8` and `as +u8`. + +" + }; +} + macro_rules! usize_isize_to_xe_bytes_doc { () => { " @@ -348,8 +373,8 @@ impl i8 { reversed = "0x48", le_bytes = "[0x12]", be_bytes = "[0x12]", - to_xe_bytes_doc = "", - from_xe_bytes_doc = "", + to_xe_bytes_doc = i8_xe_bytes_doc!(), + from_xe_bytes_doc = i8_xe_bytes_doc!(), bound_condition = "", } midpoint_impl! { i8, i16, signed } @@ -547,8 +572,8 @@ impl u8 { reversed = "0x48", le_bytes = "[0x12]", be_bytes = "[0x12]", - to_xe_bytes_doc = "", - from_xe_bytes_doc = "", + to_xe_bytes_doc = u8_xe_bytes_doc!(), + from_xe_bytes_doc = u8_xe_bytes_doc!(), bound_condition = "", } widening_impl! { u8, u16, 8, unsigned } |
