File tree Expand file tree Collapse file tree 2 files changed +13
-3
lines changed Expand file tree Collapse file tree 2 files changed +13
-3
lines changed Original file line number Diff line number Diff line change @@ -1473,9 +1473,12 @@ impl fmt::Display for ParseIntError {
1473
1473
1474
1474
pub use num:: dec2flt:: ParseFloatError ;
1475
1475
1476
- // Conversion traits for primitive integer types
1477
- // Conversions T -> T are covered by a blanket impl and therefore excluded
1478
- // Some conversions from and to usize/isize are not implemented due to portability concerns
1476
+ // Conversion traits for primitive integer types (only) where the conversion is
1477
+ // guaranteed to be lossless on all platforms. Conversions T -> T are covered
1478
+ // by a blanket impl and therefore excluded. Conversions from `usize` and
1479
+ // `isize` to other types are not implemented because there are no primitive
1480
+ // integer types that are defined to be at least as large as them on all
1481
+ // architectures.
1479
1482
macro_rules! impl_from {
1480
1483
( $Small: ty, $Large: ty) => {
1481
1484
#[ stable( feature = "lossless_int_conv" , since = "1.5.0" ) ]
@@ -1496,6 +1499,7 @@ impl_from! { u8, u64 }
1496
1499
impl_from ! { u8 , usize }
1497
1500
impl_from ! { u16 , u32 }
1498
1501
impl_from ! { u16 , u64 }
1502
+ impl_from ! { u16 , usize }
1499
1503
impl_from ! { u32 , u64 }
1500
1504
1501
1505
// Signed -> Signed
@@ -1505,12 +1509,14 @@ impl_from! { i8, i64 }
1505
1509
impl_from ! { i8 , isize }
1506
1510
impl_from ! { i16 , i32 }
1507
1511
impl_from ! { i16 , i64 }
1512
+ impl_from ! { i16 , isize }
1508
1513
impl_from ! { i32 , i64 }
1509
1514
1510
1515
// Unsigned -> Signed
1511
1516
impl_from ! { u8 , i16 }
1512
1517
impl_from ! { u8 , i32 }
1513
1518
impl_from ! { u8 , i64 }
1519
+ impl_from ! { u8 , isize }
1514
1520
impl_from ! { u16 , i32 }
1515
1521
impl_from ! { u16 , i64 }
1516
1522
impl_from ! { u32 , i64 }
Original file line number Diff line number Diff line change @@ -405,6 +405,8 @@ mod prim_u64 { }
405
405
//
406
406
/// The pointer-sized signed integer type.
407
407
///
408
+ /// `isize` is guaranteed to at least as large as `i16`.
409
+ ///
408
410
/// *[See also the `std::isize` module](isize/index.html).*
409
411
///
410
412
mod prim_isize { }
@@ -413,6 +415,8 @@ mod prim_isize { }
413
415
//
414
416
/// The pointer-sized unsigned integer type.
415
417
///
418
+ /// `usize` is guaranteed to be at least as large as `u16`.
419
+ ///
416
420
/// *[See also the `std::usize` module](usize/index.html).*
417
421
///
418
422
mod prim_usize { }
You can’t perform that action at this time.
0 commit comments