Rollup merge of #25010 - huonw:inline-int-extremes, r=alexcrichton
These compile down to `mov $CONSTANT, register; ret`, but the lack of `#[inline]` meant they have a full `call ...` when used from external crates.
This commit is contained in:
@@ -113,12 +113,14 @@ macro_rules! int_impl {
|
|||||||
$mul_with_overflow:path) => {
|
$mul_with_overflow:path) => {
|
||||||
/// Returns the smallest value that can be represented by this integer type.
|
/// Returns the smallest value that can be represented by this integer type.
|
||||||
#[stable(feature = "rust1", since = "1.0.0")]
|
#[stable(feature = "rust1", since = "1.0.0")]
|
||||||
|
#[inline]
|
||||||
pub fn min_value() -> $T {
|
pub fn min_value() -> $T {
|
||||||
(-1 as $T) << ($BITS - 1)
|
(-1 as $T) << ($BITS - 1)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns the largest value that can be represented by this integer type.
|
/// Returns the largest value that can be represented by this integer type.
|
||||||
#[stable(feature = "rust1", since = "1.0.0")]
|
#[stable(feature = "rust1", since = "1.0.0")]
|
||||||
|
#[inline]
|
||||||
pub fn max_value() -> $T {
|
pub fn max_value() -> $T {
|
||||||
let min = $T::min_value(); !min
|
let min = $T::min_value(); !min
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user