File tree Expand file tree Collapse file tree 1 file changed +7
-18
lines changed Expand file tree Collapse file tree 1 file changed +7
-18
lines changed Original file line number Diff line number Diff line change @@ -75,6 +75,7 @@ pub trait Zero: Add<Self, Self> {
75
75
fn zero() -> Self;
76
76
77
77
/// Returns `true` if `self` is equal to the additive identity.
78
+ #[inline]
78
79
fn is_zero(&self) -> bool;
79
80
}
80
81
@@ -89,32 +90,20 @@ macro_rules! zero_impl(
89
90
}
90
91
)
91
92
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
-
104
93
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)
109
98
110
99
zero_impl!(int, 0i)
111
100
zero_impl!(i8, 0i8)
112
101
zero_impl!(i16, 0i16)
113
102
zero_impl!(i32, 0i32)
114
103
zero_impl!(i64, 0i64)
115
104
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)
118
107
119
108
/// Returns the additive identity, `0`.
120
109
#[inline(always)] pub fn zero<T: Zero>() -> T { Zero::zero() }
You can’t perform that action at this time.
0 commit comments