/// assert_eq!(i8::min_value(), -128);
/// ```
#[stable(feature = "rust1", since = "1.0.0")]
+ #[cfg_attr(not(stage0), rustc_const_unstable(feature = "const_min_value"))]
#[inline]
pub const fn min_value() -> Self {
!0 ^ ((!0 as $UnsignedT) >> 1) as Self
/// assert_eq!(i8::max_value(), 127);
/// ```
#[stable(feature = "rust1", since = "1.0.0")]
+ #[cfg_attr(not(stage0), rustc_const_unstable(feature = "const_max_value"))]
#[inline]
pub const fn max_value() -> Self {
!Self::min_value()
///
/// Leading and trailing whitespace represent an error.
///
+ /// # Panics
+ ///
+ /// This function panics if `radix` is not in the range from 2 to 36.
+ ///
/// # Examples
///
/// Basic usage:
/// assert_eq!(u8::min_value(), 0);
/// ```
#[stable(feature = "rust1", since = "1.0.0")]
+ #[cfg_attr(not(stage0), rustc_const_unstable(feature = "const_min_value"))]
#[inline]
pub const fn min_value() -> Self { 0 }
/// assert_eq!(u8::max_value(), 255);
/// ```
#[stable(feature = "rust1", since = "1.0.0")]
+ #[cfg_attr(not(stage0), rustc_const_unstable(feature = "const_max_value"))]
#[inline]
pub const fn max_value() -> Self { !0 }
}
}
-#[cfg(stage0)]
-unsafe fn ctlz_nonzero<T>(x: T) -> T { intrinsics::ctlz(x) }
-#[cfg(not(stage0))]
-unsafe fn ctlz_nonzero<T>(x: T) -> T { intrinsics::ctlz_nonzero(x) }
-
#[lang = "u8"]
impl u8 {
uint_impl! { u8, u8, 8,
intrinsics::ctpop,
intrinsics::ctlz,
- ctlz_nonzero,
+ intrinsics::ctlz_nonzero,
intrinsics::cttz,
intrinsics::bswap,
intrinsics::add_with_overflow,
uint_impl! { u16, u16, 16,
intrinsics::ctpop,
intrinsics::ctlz,
- ctlz_nonzero,
+ intrinsics::ctlz_nonzero,
intrinsics::cttz,
intrinsics::bswap,
intrinsics::add_with_overflow,
uint_impl! { u32, u32, 32,
intrinsics::ctpop,
intrinsics::ctlz,
- ctlz_nonzero,
+ intrinsics::ctlz_nonzero,
intrinsics::cttz,
intrinsics::bswap,
intrinsics::add_with_overflow,
uint_impl! { u64, u64, 64,
intrinsics::ctpop,
intrinsics::ctlz,
- ctlz_nonzero,
+ intrinsics::ctlz_nonzero,
intrinsics::cttz,
intrinsics::bswap,
intrinsics::add_with_overflow,
uint_impl! { u128, u128, 128,
intrinsics::ctpop,
intrinsics::ctlz,
- ctlz_nonzero,
+ intrinsics::ctlz_nonzero,
intrinsics::cttz,
intrinsics::bswap,
intrinsics::add_with_overflow,
uint_impl! { usize, u16, 16,
intrinsics::ctpop,
intrinsics::ctlz,
- ctlz_nonzero,
+ intrinsics::ctlz_nonzero,
intrinsics::cttz,
intrinsics::bswap,
intrinsics::add_with_overflow,
uint_impl! { usize, u32, 32,
intrinsics::ctpop,
intrinsics::ctlz,
- ctlz_nonzero,
+ intrinsics::ctlz_nonzero,
intrinsics::cttz,
intrinsics::bswap,
intrinsics::add_with_overflow,
uint_impl! { usize, u64, 64,
intrinsics::ctpop,
intrinsics::ctlz,
- ctlz_nonzero,
+ intrinsics::ctlz_nonzero,
intrinsics::cttz,
intrinsics::bswap,
intrinsics::add_with_overflow,
try_from_both_bounded!(i64, u32, u16, u8);
try_from_both_bounded!(i128, u64, u32, u16, u8);
-#[unstable(feature = "try_from", issue = "33417")]
-pub use self::ptr_try_from_impls::*;
+// usize/isize
+try_from_unbounded!(usize, usize);
+try_from_upper_bounded!(usize, isize);
+try_from_lower_bounded!(isize, usize);
+try_from_unbounded!(isize, isize);
#[cfg(target_pointer_width = "16")]
mod ptr_try_from_impls {
use convert::TryFrom;
try_from_upper_bounded!(usize, u8);
- try_from_unbounded!(usize, usize, u16, u32, u64, u128);
- try_from_upper_bounded!(usize, i8, i16, isize);
+ try_from_unbounded!(usize, u16, u32, u64, u128);
+ try_from_upper_bounded!(usize, i8, i16);
try_from_unbounded!(usize, i32, i64, i128);
try_from_both_bounded!(isize, u8);
- try_from_lower_bounded!(isize, usize, u16, u32, u64, u128);
+ try_from_lower_bounded!(isize, u16, u32, u64, u128);
try_from_both_bounded!(isize, i8);
try_from_unbounded!(isize, i16, i32, i64, i128);
use convert::TryFrom;
try_from_upper_bounded!(usize, u8, u16);
- try_from_unbounded!(usize, usize, u32, u64, u128);
- try_from_upper_bounded!(usize, i8, i16, i32, isize);
+ try_from_unbounded!(usize, u32, u64, u128);
+ try_from_upper_bounded!(usize, i8, i16, i32);
try_from_unbounded!(usize, i64, i128);
try_from_both_bounded!(isize, u8, u16);
- try_from_lower_bounded!(isize, usize, u32, u64, u128);
+ try_from_lower_bounded!(isize, u32, u64, u128);
try_from_both_bounded!(isize, i8, i16);
try_from_unbounded!(isize, i32, i64, i128);
use convert::TryFrom;
try_from_upper_bounded!(usize, u8, u16, u32);
- try_from_unbounded!(usize, usize, u64, u128);
- try_from_upper_bounded!(usize, i8, i16, i32, i64, isize);
+ try_from_unbounded!(usize, u64, u128);
+ try_from_upper_bounded!(usize, i8, i16, i32, i64);
try_from_unbounded!(usize, i128);
try_from_both_bounded!(isize, u8, u16, u32);
- try_from_lower_bounded!(isize, usize, u64, u128);
+ try_from_lower_bounded!(isize, u64, u128);
try_from_both_bounded!(isize, i8, i16, i32);
try_from_unbounded!(isize, i64, i128);