Skip to content

Commit c09c038

Browse files
author
Robert Gawdzik ☢
committed
Added a note for usage of abs with ::MIN.
1 parent 1cad408 commit c09c038

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/libcore/num/mod.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,8 @@ pub trait Signed: Num + Neg<Self> {
160160
/// Computes the absolute value.
161161
///
162162
/// For `f32` and `f64`, `NaN` will be returned if the number is `NaN`.
163+
///
164+
/// For signed integers, `::MIN` will be returned if the number is `::MIN`.
163165
fn abs(&self) -> Self;
164166

165167
/// The positive difference of two numbers.
@@ -176,7 +178,7 @@ pub trait Signed: Num + Neg<Self> {
176178
/// * `-1.0` if the number is negative, `-0.0` or `NEG_INFINITY`
177179
/// * `NaN` if the number is `NaN`
178180
///
179-
/// For `int`:
181+
/// For signed integers:
180182
///
181183
/// * `0` if the number is zero
182184
/// * `1` if the number is positive
@@ -272,6 +274,8 @@ signed_float_impl!(f64, f64::NAN, f64::INFINITY, f64::NEG_INFINITY,
272274
/// Computes the absolute value.
273275
///
274276
/// For `f32` and `f64`, `NaN` will be returned if the number is `NaN`
277+
///
278+
/// For signed integers, `::MIN` will be returned if the number is `::MIN`.
275279
#[inline(always)]
276280
pub fn abs<T: Signed>(value: T) -> T {
277281
value.abs()
@@ -294,7 +298,7 @@ pub fn abs_sub<T: Signed>(x: T, y: T) -> T {
294298
/// * `-1.0` if the number is negative, `-0.0` or `NEG_INFINITY`
295299
/// * `NaN` if the number is `NaN`
296300
///
297-
/// For int:
301+
/// For signed integers:
298302
///
299303
/// * `0` if the number is zero
300304
/// * `1` if the number is positive

0 commit comments

Comments
 (0)