Skip to content

Commit 6850e4a

Browse files
committed
Use assoc float consts instead of module level
1 parent 4ddf661 commit 6850e4a

File tree

5 files changed

+15
-16
lines changed

5 files changed

+15
-16
lines changed

src/libcore/num/f32.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,7 @@ impl f32 {
265265
#[stable(feature = "rust1", since = "1.0.0")]
266266
#[inline]
267267
pub fn is_infinite(self) -> bool {
268-
self.abs_private() == INFINITY
268+
self.abs_private() == Self::INFINITY
269269
}
270270

271271
/// Returns `true` if this number is neither infinite nor `NaN`.
@@ -287,7 +287,7 @@ impl f32 {
287287
pub fn is_finite(self) -> bool {
288288
// There's no need to handle NaN separately: if self is NaN,
289289
// the comparison is not true, exactly as desired.
290-
self.abs_private() < INFINITY
290+
self.abs_private() < Self::INFINITY
291291
}
292292

293293
/// Returns `true` if the number is neither zero, infinite,

src/libcore/num/f64.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,7 @@ impl f64 {
264264
#[stable(feature = "rust1", since = "1.0.0")]
265265
#[inline]
266266
pub fn is_infinite(self) -> bool {
267-
self.abs_private() == INFINITY
267+
self.abs_private() == Self::INFINITY
268268
}
269269

270270
/// Returns `true` if this number is neither infinite nor `NaN`.
@@ -286,7 +286,7 @@ impl f64 {
286286
pub fn is_finite(self) -> bool {
287287
// There's no need to handle NaN separately: if self is NaN,
288288
// the comparison is not true, exactly as desired.
289-
self.abs_private() < INFINITY
289+
self.abs_private() < Self::INFINITY
290290
}
291291

292292
/// Returns `true` if the number is neither zero, infinite,

src/libcore/num/flt2dec/decoder.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
33
use crate::num::dec2flt::rawfp::RawFloat;
44
use crate::num::FpCategory;
5-
use crate::{f32, f64};
65

76
/// Decoded unsigned finite value, such that:
87
///

src/libstd/f32.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ impl f32 {
171171
#[stable(feature = "rust1", since = "1.0.0")]
172172
#[inline]
173173
pub fn signum(self) -> f32 {
174-
if self.is_nan() { NAN } else { 1.0_f32.copysign(self) }
174+
if self.is_nan() { Self::NAN } else { 1.0_f32.copysign(self) }
175175
}
176176

177177
/// Returns a number composed of the magnitude of `self` and the sign of
@@ -832,8 +832,8 @@ impl f32 {
832832
#[stable(feature = "rust1", since = "1.0.0")]
833833
#[inline]
834834
pub fn asinh(self) -> f32 {
835-
if self == NEG_INFINITY {
836-
NEG_INFINITY
835+
if self == Self::NEG_INFINITY {
836+
Self::NEG_INFINITY
837837
} else {
838838
(self + ((self * self) + 1.0).sqrt()).ln().copysign(self)
839839
}
@@ -855,7 +855,7 @@ impl f32 {
855855
#[stable(feature = "rust1", since = "1.0.0")]
856856
#[inline]
857857
pub fn acosh(self) -> f32 {
858-
if self < 1.0 { crate::f32::NAN } else { (self + ((self * self) - 1.0).sqrt()).ln() }
858+
if self < 1.0 { Self::NAN } else { (self + ((self * self) - 1.0).sqrt()).ln() }
859859
}
860860

861861
/// Inverse hyperbolic tangent function.

src/libstd/f64.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ impl f64 {
171171
#[stable(feature = "rust1", since = "1.0.0")]
172172
#[inline]
173173
pub fn signum(self) -> f64 {
174-
if self.is_nan() { NAN } else { 1.0_f64.copysign(self) }
174+
if self.is_nan() { Self::NAN } else { 1.0_f64.copysign(self) }
175175
}
176176

177177
/// Returns a number composed of the magnitude of `self` and the sign of
@@ -834,8 +834,8 @@ impl f64 {
834834
#[stable(feature = "rust1", since = "1.0.0")]
835835
#[inline]
836836
pub fn asinh(self) -> f64 {
837-
if self == NEG_INFINITY {
838-
NEG_INFINITY
837+
if self == Self::NEG_INFINITY {
838+
Self::NEG_INFINITY
839839
} else {
840840
(self + ((self * self) + 1.0).sqrt()).ln().copysign(self)
841841
}
@@ -857,7 +857,7 @@ impl f64 {
857857
#[stable(feature = "rust1", since = "1.0.0")]
858858
#[inline]
859859
pub fn acosh(self) -> f64 {
860-
if self < 1.0 { NAN } else { (self + ((self * self) - 1.0).sqrt()).ln() }
860+
if self < 1.0 { Self::NAN } else { (self + ((self * self) - 1.0).sqrt()).ln() }
861861
}
862862

863863
/// Inverse hyperbolic tangent function.
@@ -926,16 +926,16 @@ impl f64 {
926926
if self > 0.0 {
927927
log_fn(self)
928928
} else if self == 0.0 {
929-
NEG_INFINITY // log(0) = -Inf
929+
Self::NEG_INFINITY // log(0) = -Inf
930930
} else {
931-
NAN // log(-n) = NaN
931+
Self::NAN // log(-n) = NaN
932932
}
933933
} else if self.is_nan() {
934934
self // log(NaN) = NaN
935935
} else if self > 0.0 {
936936
self // log(Inf) = Inf
937937
} else {
938-
NAN // log(-Inf) = NaN
938+
Self::NAN // log(-Inf) = NaN
939939
}
940940
}
941941
}

0 commit comments

Comments
 (0)