Skip to content

Make min_value() and max_value() const functions #29862

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 16, 2015
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions src/libcore/num/mod.rs
Original file line number Diff line number Diff line change
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