diff options
| author | bors <bors@rust-lang.org> | 2015-11-16 20:53:59 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2015-11-16 20:53:59 +0000 |
| commit | 73cfcc60e1d776c748269bf1fe411a087cb26076 (patch) | |
| tree | 05c5b7ae38b55fcab37ce331f3ffa0743b7f598a | |
| parent | 99093b79f112c5decd555103c890c6af15ed0c68 (diff) | |
| parent | c545b33a7d959a05bcfc7ef6b4c303b6b87870ac (diff) | |
| download | rust-73cfcc60e1d776c748269bf1fe411a087cb26076.tar.gz rust-73cfcc60e1d776c748269bf1fe411a087cb26076.zip | |
Auto merge of #29862 - ranma42:const_min_max, r=alexcrichton
They can be useful for constructing constant items.
| -rw-r--r-- | src/libcore/num/mod.rs | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/src/libcore/num/mod.rs b/src/libcore/num/mod.rs index 3afc89c9841..c0f65fea7db 100644 --- a/src/libcore/num/mod.rs +++ b/src/libcore/num/mod.rs @@ -124,15 +124,15 @@ macro_rules! int_impl { /// Returns the smallest value that can be represented by this integer type. #[stable(feature = "rust1", since = "1.0.0")] #[inline] - pub fn min_value() -> Self { + pub const fn min_value() -> Self { (-1 as Self) << ($BITS - 1) } /// Returns the largest value that can be represented by this integer type. #[stable(feature = "rust1", since = "1.0.0")] #[inline] - pub fn max_value() -> Self { - let min = Self::min_value(); !min + pub const fn max_value() -> Self { + !Self::min_value() } /// Converts a string slice in a given base to an integer. @@ -891,12 +891,12 @@ macro_rules! uint_impl { /// Returns the smallest value that can be represented by this integer type. #[stable(feature = "rust1", since = "1.0.0")] #[inline] - pub fn min_value() -> Self { 0 } + pub const fn min_value() -> Self { 0 } /// Returns the largest value that can be represented by this integer type. #[stable(feature = "rust1", since = "1.0.0")] #[inline] - pub fn max_value() -> Self { !0 } + pub const fn max_value() -> Self { !0 } /// Converts a string slice in a given base to an integer. /// |
