Skip to content

Commit b13d6ea

Browse files
committed
auto merge of rust-lang#15900 : tbu-/rust/pr_numcleanup, r=kballard
This removes the special casing for `float`s where it was not necessary, as `-0.0 == 0.0`.
2 parents 83a8a56 + 737d92e commit b13d6ea

File tree

1 file changed

+7
-18
lines changed

1 file changed

+7
-18
lines changed

src/libcore/num/mod.rs

+7-18
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ pub trait Zero: Add<Self, Self> {
7575
fn zero() -> Self;
7676

7777
/// Returns `true` if `self` is equal to the additive identity.
78+
#[inline]
7879
fn is_zero(&self) -> bool;
7980
}
8081

@@ -89,32 +90,20 @@ macro_rules! zero_impl(
8990
}
9091
)
9192

92-
macro_rules! zero_float_impl(
93-
($t:ty, $v:expr) => {
94-
impl Zero for $t {
95-
#[inline]
96-
fn zero() -> $t { $v }
97-
98-
#[inline]
99-
fn is_zero(&self) -> bool { *self == $v || *self == -$v }
100-
}
101-
}
102-
)
103-
10493
zero_impl!(uint, 0u)
105-
zero_impl!(u8, 0u8)
106-
zero_impl!(u16, 0u16)
107-
zero_impl!(u32, 0u32)
108-
zero_impl!(u64, 0u64)
94+
zero_impl!(u8, 0u8)
95+
zero_impl!(u16, 0u16)
96+
zero_impl!(u32, 0u32)
97+
zero_impl!(u64, 0u64)
10998

11099
zero_impl!(int, 0i)
111100
zero_impl!(i8, 0i8)
112101
zero_impl!(i16, 0i16)
113102
zero_impl!(i32, 0i32)
114103
zero_impl!(i64, 0i64)
115104

116-
zero_float_impl!(f32, 0.0f32)
117-
zero_float_impl!(f64, 0.0f64)
105+
zero_impl!(f32, 0.0f32)
106+
zero_impl!(f64, 0.0f64)
118107

119108
/// Returns the additive identity, `0`.
120109
#[inline(always)] pub fn zero<T: Zero>() -> T { Zero::zero() }

0 commit comments

Comments
 (0)