@@ -214,11 +214,31 @@ pub mod diy_float;
214
214
215
215
mod wrapping;
216
216
217
+ macro_rules! usize_isize_to_xe_bytes_doc {
218
+ ( ) => { "
219
+
220
+ **Note**: This function returns an array of length 2, 4 or 8 bytes
221
+ depending on the target pointer size.
222
+
223
+ " }
224
+ }
225
+
226
+
227
+ macro_rules! usize_isize_from_xe_bytes_doc {
228
+ ( ) => { "
229
+
230
+ **Note**: This function takes an array of length 2, 4 or 8 bytes
231
+ depending on the target pointer size.
232
+
233
+ " }
234
+ }
235
+
217
236
// `Int` + `SignedInt` implemented for signed integers
218
237
macro_rules! int_impl {
219
238
( $SelfT: ty, $ActualT: ident, $UnsignedT: ty, $BITS: expr, $Min: expr, $Max: expr, $Feature: expr,
220
239
$EndFeature: expr, $rot: expr, $rot_op: expr, $rot_result: expr, $swap_op: expr, $swapped: expr,
221
- $reversed: expr, $le_bytes: expr, $be_bytes: expr) => {
240
+ $reversed: expr, $le_bytes: expr, $be_bytes: expr,
241
+ $to_xe_bytes_doc: expr, $from_xe_bytes_doc: expr) => {
222
242
doc_comment! {
223
243
concat!( "Returns the smallest value that can be represented by this integer type.
224
244
@@ -2023,7 +2043,9 @@ $EndFeature, "
2023
2043
doc_comment! {
2024
2044
concat!( "Return the memory representation of this integer as a byte array in
2025
2045
big-endian (network) byte order.
2026
-
2046
+ " ,
2047
+ $to_xe_bytes_doc,
2048
+ "
2027
2049
# Examples
2028
2050
2029
2051
```
@@ -2041,7 +2063,9 @@ assert_eq!(bytes, ", $be_bytes, ");
2041
2063
doc_comment! {
2042
2064
concat!( "Return the memory representation of this integer as a byte array in
2043
2065
little-endian byte order.
2044
-
2066
+ " ,
2067
+ $to_xe_bytes_doc,
2068
+ "
2045
2069
# Examples
2046
2070
2047
2071
```
@@ -2064,7 +2088,9 @@ native byte order.
2064
2088
As the target platform's native endianness is used, portable code
2065
2089
should use [`to_be_bytes`] or [`to_le_bytes`], as appropriate,
2066
2090
instead.
2067
-
2091
+ " ,
2092
+ $to_xe_bytes_doc,
2093
+ "
2068
2094
[`to_be_bytes`]: #method.to_be_bytes
2069
2095
[`to_le_bytes`]: #method.to_le_bytes
2070
2096
@@ -2089,7 +2115,9 @@ assert_eq!(bytes, if cfg!(target_endian = \"big\") {
2089
2115
doc_comment! {
2090
2116
concat!( "Create an integer value from its representation as a byte array in
2091
2117
big endian.
2092
-
2118
+ " ,
2119
+ $from_xe_bytes_doc,
2120
+ "
2093
2121
# Examples
2094
2122
2095
2123
```
@@ -2120,7 +2148,9 @@ doc_comment! {
2120
2148
concat!( "
2121
2149
Create an integer value from its representation as a byte array in
2122
2150
little endian.
2123
-
2151
+ " ,
2152
+ $from_xe_bytes_doc,
2153
+ "
2124
2154
# Examples
2125
2155
2126
2156
```
@@ -2157,7 +2187,9 @@ appropriate instead.
2157
2187
2158
2188
[`from_be_bytes`]: #method.from_be_bytes
2159
2189
[`from_le_bytes`]: #method.from_le_bytes
2160
-
2190
+ " ,
2191
+ $from_xe_bytes_doc,
2192
+ "
2161
2193
# Examples
2162
2194
2163
2195
```
@@ -2193,28 +2225,28 @@ fn read_ne_", stringify!($SelfT), "(input: &mut &[u8]) -> ", stringify!($SelfT),
2193
2225
#[ lang = "i8" ]
2194
2226
impl i8 {
2195
2227
int_impl ! { i8 , i8 , u8 , 8 , -128 , 127 , "" , "" , 2 , "-0x7e" , "0xa" , "0x12" , "0x12" , "0x48" ,
2196
- "[0x12]" , "[0x12]" }
2228
+ "[0x12]" , "[0x12]" , "" , "" }
2197
2229
}
2198
2230
2199
2231
#[ lang = "i16" ]
2200
2232
impl i16 {
2201
2233
int_impl ! { i16 , i16 , u16 , 16 , -32768 , 32767 , "" , "" , 4 , "-0x5ffd" , "0x3a" , "0x1234" , "0x3412" ,
2202
- "0x2c48" , "[0x34, 0x12]" , "[0x12, 0x34]" }
2234
+ "0x2c48" , "[0x34, 0x12]" , "[0x12, 0x34]" , "" , "" }
2203
2235
}
2204
2236
2205
2237
#[ lang = "i32" ]
2206
2238
impl i32 {
2207
2239
int_impl ! { i32 , i32 , u32 , 32 , -2147483648 , 2147483647 , "" , "" , 8 , "0x10000b3" , "0xb301" ,
2208
2240
"0x12345678" , "0x78563412" , "0x1e6a2c48" , "[0x78, 0x56, 0x34, 0x12]" ,
2209
- "[0x12, 0x34, 0x56, 0x78]" }
2241
+ "[0x12, 0x34, 0x56, 0x78]" , "" , "" }
2210
2242
}
2211
2243
2212
2244
#[ lang = "i64" ]
2213
2245
impl i64 {
2214
2246
int_impl ! { i64 , i64 , u64 , 64 , -9223372036854775808 , 9223372036854775807 , "" , "" , 12 ,
2215
2247
"0xaa00000000006e1" , "0x6e10aa" , "0x1234567890123456" , "0x5634129078563412" ,
2216
2248
"0x6a2c48091e6a2c48" , "[0x56, 0x34, 0x12, 0x90, 0x78, 0x56, 0x34, 0x12]" ,
2217
- "[0x12, 0x34, 0x56, 0x78, 0x90, 0x12, 0x34, 0x56]" }
2249
+ "[0x12, 0x34, 0x56, 0x78, 0x90, 0x12, 0x34, 0x56]" , "" , "" }
2218
2250
}
2219
2251
2220
2252
#[ lang = "i128" ]
@@ -2226,22 +2258,24 @@ impl i128 {
2226
2258
"[0x12, 0x90, 0x78, 0x56, 0x34, 0x12, 0x90, 0x78, \
2227
2259
0x56, 0x34, 0x12, 0x90, 0x78, 0x56, 0x34, 0x12]",
2228
2260
"[0x12, 0x34, 0x56, 0x78, 0x90, 0x12, 0x34, 0x56, \
2229
- 0x78, 0x90, 0x12, 0x34, 0x56, 0x78, 0x90, 0x12]" }
2261
+ 0x78, 0x90, 0x12, 0x34, 0x56, 0x78, 0x90, 0x12]", "" , "" }
2230
2262
}
2231
2263
2232
2264
#[ cfg( target_pointer_width = "16" ) ]
2233
2265
#[ lang = "isize" ]
2234
2266
impl isize {
2235
2267
int_impl ! { isize , i16 , u16 , 16 , -32768 , 32767 , "" , "" , 4 , "-0x5ffd" , "0x3a" , "0x1234" ,
2236
- "0x3412" , "0x2c48" , "[0x34, 0x12]" , "[0x12, 0x34]" }
2268
+ "0x3412" , "0x2c48" , "[0x34, 0x12]" , "[0x12, 0x34]" ,
2269
+ usize_isize_to_xe_bytes_doc!( ) , usize_isize_from_xe_bytes_doc!( ) }
2237
2270
}
2238
2271
2239
2272
#[ cfg( target_pointer_width = "32" ) ]
2240
2273
#[ lang = "isize" ]
2241
2274
impl isize {
2242
2275
int_impl ! { isize , i32 , u32 , 32 , -2147483648 , 2147483647 , "" , "" , 8 , "0x10000b3" , "0xb301" ,
2243
2276
"0x12345678" , "0x78563412" , "0x1e6a2c48" , "[0x78, 0x56, 0x34, 0x12]" ,
2244
- "[0x12, 0x34, 0x56, 0x78]" }
2277
+ "[0x12, 0x34, 0x56, 0x78]" ,
2278
+ usize_isize_to_xe_bytes_doc!( ) , usize_isize_from_xe_bytes_doc!( ) }
2245
2279
}
2246
2280
2247
2281
#[ cfg( target_pointer_width = "64" ) ]
@@ -2250,14 +2284,16 @@ impl isize {
2250
2284
int_impl ! { isize , i64 , u64 , 64 , -9223372036854775808 , 9223372036854775807 , "" , "" ,
2251
2285
12 , "0xaa00000000006e1" , "0x6e10aa" , "0x1234567890123456" , "0x5634129078563412" ,
2252
2286
"0x6a2c48091e6a2c48" , "[0x56, 0x34, 0x12, 0x90, 0x78, 0x56, 0x34, 0x12]" ,
2253
- "[0x12, 0x34, 0x56, 0x78, 0x90, 0x12, 0x34, 0x56]" }
2287
+ "[0x12, 0x34, 0x56, 0x78, 0x90, 0x12, 0x34, 0x56]" ,
2288
+ usize_isize_to_xe_bytes_doc!( ) , usize_isize_from_xe_bytes_doc!( ) }
2254
2289
}
2255
2290
2256
2291
// `Int` + `UnsignedInt` implemented for unsigned integers
2257
2292
macro_rules! uint_impl {
2258
2293
( $SelfT: ty, $ActualT: ty, $BITS: expr, $MaxV: expr, $Feature: expr, $EndFeature: expr,
2259
2294
$rot: expr, $rot_op: expr, $rot_result: expr, $swap_op: expr, $swapped: expr,
2260
- $reversed: expr, $le_bytes: expr, $be_bytes: expr) => {
2295
+ $reversed: expr, $le_bytes: expr, $be_bytes: expr,
2296
+ $to_xe_bytes_doc: expr, $from_xe_bytes_doc: expr) => {
2261
2297
doc_comment! {
2262
2298
concat!( "Returns the smallest value that can be represented by this integer type.
2263
2299
@@ -3817,7 +3853,9 @@ $EndFeature, "
3817
3853
doc_comment! {
3818
3854
concat!( "Return the memory representation of this integer as a byte array in
3819
3855
big-endian (network) byte order.
3820
-
3856
+ " ,
3857
+ $to_xe_bytes_doc,
3858
+ "
3821
3859
# Examples
3822
3860
3823
3861
```
@@ -3835,7 +3873,9 @@ assert_eq!(bytes, ", $be_bytes, ");
3835
3873
doc_comment! {
3836
3874
concat!( "Return the memory representation of this integer as a byte array in
3837
3875
little-endian byte order.
3838
-
3876
+ " ,
3877
+ $to_xe_bytes_doc,
3878
+ "
3839
3879
# Examples
3840
3880
3841
3881
```
@@ -3858,7 +3898,9 @@ native byte order.
3858
3898
As the target platform's native endianness is used, portable code
3859
3899
should use [`to_be_bytes`] or [`to_le_bytes`], as appropriate,
3860
3900
instead.
3861
-
3901
+ " ,
3902
+ $to_xe_bytes_doc,
3903
+ "
3862
3904
[`to_be_bytes`]: #method.to_be_bytes
3863
3905
[`to_le_bytes`]: #method.to_le_bytes
3864
3906
@@ -3883,7 +3925,9 @@ assert_eq!(bytes, if cfg!(target_endian = \"big\") {
3883
3925
doc_comment! {
3884
3926
concat!( "Create an integer value from its representation as a byte array in
3885
3927
big endian.
3886
-
3928
+ " ,
3929
+ $from_xe_bytes_doc,
3930
+ "
3887
3931
# Examples
3888
3932
3889
3933
```
@@ -3914,7 +3958,9 @@ fn read_be_", stringify!($SelfT), "(input: &mut &[u8]) -> ", stringify!($SelfT),
3914
3958
concat!( "
3915
3959
Create an integer value from its representation as a byte array in
3916
3960
little endian.
3917
-
3961
+ " ,
3962
+ $from_xe_bytes_doc,
3963
+ "
3918
3964
# Examples
3919
3965
3920
3966
```
@@ -3951,7 +3997,9 @@ appropriate instead.
3951
3997
3952
3998
[`from_be_bytes`]: #method.from_be_bytes
3953
3999
[`from_le_bytes`]: #method.from_le_bytes
3954
-
4000
+ " ,
4001
+ $from_xe_bytes_doc,
4002
+ "
3955
4003
# Examples
3956
4004
3957
4005
```
@@ -3987,7 +4035,7 @@ fn read_ne_", stringify!($SelfT), "(input: &mut &[u8]) -> ", stringify!($SelfT),
3987
4035
#[ lang = "u8" ]
3988
4036
impl u8 {
3989
4037
uint_impl ! { u8 , u8 , 8 , 255 , "" , "" , 2 , "0x82" , "0xa" , "0x12" , "0x12" , "0x48" , "[0x12]" ,
3990
- "[0x12]" }
4038
+ "[0x12]" , "" , "" }
3991
4039
3992
4040
3993
4041
/// Checks if the value is within the ASCII range.
@@ -4506,21 +4554,22 @@ impl u8 {
4506
4554
#[ lang = "u16" ]
4507
4555
impl u16 {
4508
4556
uint_impl ! { u16 , u16 , 16 , 65535 , "" , "" , 4 , "0xa003" , "0x3a" , "0x1234" , "0x3412" , "0x2c48" ,
4509
- "[0x34, 0x12]" , "[0x12, 0x34]" }
4557
+ "[0x34, 0x12]" , "[0x12, 0x34]" , "" , "" }
4510
4558
}
4511
4559
4512
4560
#[ lang = "u32" ]
4513
4561
impl u32 {
4514
4562
uint_impl ! { u32 , u32 , 32 , 4294967295 , "" , "" , 8 , "0x10000b3" , "0xb301" , "0x12345678" ,
4515
- "0x78563412" , "0x1e6a2c48" , "[0x78, 0x56, 0x34, 0x12]" , "[0x12, 0x34, 0x56, 0x78]" }
4563
+ "0x78563412" , "0x1e6a2c48" , "[0x78, 0x56, 0x34, 0x12]" , "[0x12, 0x34, 0x56, 0x78]" , "" , "" }
4516
4564
}
4517
4565
4518
4566
#[ lang = "u64" ]
4519
4567
impl u64 {
4520
4568
uint_impl ! { u64 , u64 , 64 , 18446744073709551615 , "" , "" , 12 , "0xaa00000000006e1" , "0x6e10aa" ,
4521
4569
"0x1234567890123456" , "0x5634129078563412" , "0x6a2c48091e6a2c48" ,
4522
4570
"[0x56, 0x34, 0x12, 0x90, 0x78, 0x56, 0x34, 0x12]" ,
4523
- "[0x12, 0x34, 0x56, 0x78, 0x90, 0x12, 0x34, 0x56]" }
4571
+ "[0x12, 0x34, 0x56, 0x78, 0x90, 0x12, 0x34, 0x56]" ,
4572
+ "" , "" }
4524
4573
}
4525
4574
4526
4575
#[ lang = "u128" ]
@@ -4531,20 +4580,23 @@ impl u128 {
4531
4580
"[0x12, 0x90, 0x78, 0x56, 0x34, 0x12, 0x90, 0x78, \
4532
4581
0x56, 0x34, 0x12, 0x90, 0x78, 0x56, 0x34, 0x12]",
4533
4582
"[0x12, 0x34, 0x56, 0x78, 0x90, 0x12, 0x34, 0x56, \
4534
- 0x78, 0x90, 0x12, 0x34, 0x56, 0x78, 0x90, 0x12]" }
4583
+ 0x78, 0x90, 0x12, 0x34, 0x56, 0x78, 0x90, 0x12]",
4584
+ "" , "" }
4535
4585
}
4536
4586
4537
4587
#[ cfg( target_pointer_width = "16" ) ]
4538
4588
#[ lang = "usize" ]
4539
4589
impl usize {
4540
4590
uint_impl ! { usize , u16 , 16 , 65535 , "" , "" , 4 , "0xa003" , "0x3a" , "0x1234" , "0x3412" , "0x2c48" ,
4541
- "[0x34, 0x12]" , "[0x12, 0x34]" }
4591
+ "[0x34, 0x12]" , "[0x12, 0x34]" ,
4592
+ usize_isize_to_xe_bytes_doc!( ) , usize_isize_from_xe_bytes_doc!( ) }
4542
4593
}
4543
4594
#[ cfg( target_pointer_width = "32" ) ]
4544
4595
#[ lang = "usize" ]
4545
4596
impl usize {
4546
4597
uint_impl ! { usize , u32 , 32 , 4294967295 , "" , "" , 8 , "0x10000b3" , "0xb301" , "0x12345678" ,
4547
- "0x78563412" , "0x1e6a2c48" , "[0x78, 0x56, 0x34, 0x12]" , "[0x12, 0x34, 0x56, 0x78]" }
4598
+ "0x78563412" , "0x1e6a2c48" , "[0x78, 0x56, 0x34, 0x12]" , "[0x12, 0x34, 0x56, 0x78]" ,
4599
+ usize_isize_to_xe_bytes_doc!( ) , usize_isize_from_xe_bytes_doc!( ) }
4548
4600
}
4549
4601
4550
4602
#[ cfg( target_pointer_width = "64" ) ]
@@ -4553,7 +4605,8 @@ impl usize {
4553
4605
uint_impl ! { usize , u64 , 64 , 18446744073709551615 , "" , "" , 12 , "0xaa00000000006e1" , "0x6e10aa" ,
4554
4606
"0x1234567890123456" , "0x5634129078563412" , "0x6a2c48091e6a2c48" ,
4555
4607
"[0x56, 0x34, 0x12, 0x90, 0x78, 0x56, 0x34, 0x12]" ,
4556
- "[0x12, 0x34, 0x56, 0x78, 0x90, 0x12, 0x34, 0x56]" }
4608
+ "[0x12, 0x34, 0x56, 0x78, 0x90, 0x12, 0x34, 0x56]" ,
4609
+ usize_isize_to_xe_bytes_doc!( ) , usize_isize_from_xe_bytes_doc!( ) }
4557
4610
}
4558
4611
4559
4612
/// A classification of floating point numbers.
0 commit comments