Impl int/uint::MIN/MAX in terms of min/max_value
This commit is contained in:
@@ -10,6 +10,7 @@
|
|||||||
|
|
||||||
#![doc(hidden)]
|
#![doc(hidden)]
|
||||||
|
|
||||||
|
#[cfg(stage0)]
|
||||||
macro_rules! int_module { ($T:ty, $bits:expr) => (
|
macro_rules! int_module { ($T:ty, $bits:expr) => (
|
||||||
|
|
||||||
// FIXME(#11621): Should be deprecated once CTFE is implemented in favour of
|
// FIXME(#11621): Should be deprecated once CTFE is implemented in favour of
|
||||||
@@ -25,3 +26,15 @@ pub const MIN: $T = (-1 as $T) << ($bits - 1);
|
|||||||
pub const MAX: $T = !MIN;
|
pub const MAX: $T = !MIN;
|
||||||
|
|
||||||
) }
|
) }
|
||||||
|
|
||||||
|
#[cfg(not(stage0))]
|
||||||
|
macro_rules! int_module { ($T:ident, $bits:expr) => (
|
||||||
|
|
||||||
|
#[stable(feature = "rust1", since = "1.0.0")]
|
||||||
|
#[allow(missing_docs)]
|
||||||
|
pub const MIN: $T = $T::min_value();
|
||||||
|
#[stable(feature = "rust1", since = "1.0.0")]
|
||||||
|
#[allow(missing_docs)]
|
||||||
|
pub const MAX: $T = $T::max_value();
|
||||||
|
|
||||||
|
) }
|
||||||
|
|||||||
@@ -10,6 +10,7 @@
|
|||||||
|
|
||||||
#![doc(hidden)]
|
#![doc(hidden)]
|
||||||
|
|
||||||
|
#[cfg(stage0)]
|
||||||
macro_rules! uint_module { ($T:ty, $bits:expr) => (
|
macro_rules! uint_module { ($T:ty, $bits:expr) => (
|
||||||
|
|
||||||
#[stable(feature = "rust1", since = "1.0.0")]
|
#[stable(feature = "rust1", since = "1.0.0")]
|
||||||
@@ -20,3 +21,15 @@ pub const MIN: $T = 0 as $T;
|
|||||||
pub const MAX: $T = !0 as $T;
|
pub const MAX: $T = !0 as $T;
|
||||||
|
|
||||||
) }
|
) }
|
||||||
|
|
||||||
|
#[cfg(not(stage0))]
|
||||||
|
macro_rules! uint_module { ($T:ident, $bits:expr) => (
|
||||||
|
|
||||||
|
#[stable(feature = "rust1", since = "1.0.0")]
|
||||||
|
#[allow(missing_docs)]
|
||||||
|
pub const MIN: $T = $T::min_value();
|
||||||
|
#[stable(feature = "rust1", since = "1.0.0")]
|
||||||
|
#[allow(missing_docs)]
|
||||||
|
pub const MAX: $T = $T::max_value();
|
||||||
|
|
||||||
|
) }
|
||||||
|
|||||||
Reference in New Issue
Block a user