1
Fork 0

Impl int/uint::MIN/MAX in terms of min/max_value

This commit is contained in:
Simonas Kazlauskas 2016-04-30 03:40:34 +03:00
parent 5f956103c8
commit 04f8ba2ece
2 changed files with 26 additions and 0 deletions

View file

@ -10,6 +10,7 @@
#![doc(hidden)]
#[cfg(stage0)]
macro_rules! int_module { ($T:ty, $bits:expr) => (
// 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;
) }
#[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();
) }

View file

@ -10,6 +10,7 @@
#![doc(hidden)]
#[cfg(stage0)]
macro_rules! uint_module { ($T:ty, $bits:expr) => (
#[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;
) }
#[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();
) }