Skip to content

Commit

Permalink
Make min_value() and max_value() const functions
Browse files Browse the repository at this point in the history
  • Loading branch information
ranma42 committed Nov 16, 2015
1 parent 57c8a3e commit c545b33
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/libcore/num/mod.rs
Expand Up @@ -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.
Expand Down Expand Up @@ -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.
///
Expand Down

0 comments on commit c545b33

Please sign in to comment.