@@ -30,7 +30,7 @@ use core::str::FromStr;
30
30
#[ cfg( feature = "std" ) ]
31
31
use std:: error:: Error ;
32
32
33
- use num_traits:: { Inv , MulAdd , Num , One , Pow , Signed , Zero } ;
33
+ use num_traits:: { ConstOne , ConstZero , Inv , MulAdd , Num , One , Pow , Signed , Zero } ;
34
34
35
35
use num_traits:: float:: FloatCore ;
36
36
#[ cfg( any( feature = "std" , feature = "libm" ) ) ]
@@ -1146,6 +1146,15 @@ impl<T: Clone + Num> Rem<T> for Complex<T> {
1146
1146
real_arithmetic ! ( usize , u8 , u16 , u32 , u64 , u128 , isize , i8 , i16 , i32 , i64 , i128 , f32 , f64 ) ;
1147
1147
1148
1148
// constants
1149
+ impl < T : ConstZero > Complex < T > {
1150
+ /// A constant `Complex` 0.
1151
+ pub const ZERO : Self = Self :: new ( T :: ZERO , T :: ZERO ) ;
1152
+ }
1153
+
1154
+ impl < T : Clone + Num + ConstZero > ConstZero for Complex < T > {
1155
+ const ZERO : Self = Self :: ZERO ;
1156
+ }
1157
+
1149
1158
impl < T : Clone + Num > Zero for Complex < T > {
1150
1159
#[ inline]
1151
1160
fn zero ( ) -> Self {
@@ -1164,6 +1173,15 @@ impl<T: Clone + Num> Zero for Complex<T> {
1164
1173
}
1165
1174
}
1166
1175
1176
+ impl < T : ConstOne + ConstZero > Complex < T > {
1177
+ /// A constant `Complex` 1.
1178
+ pub const ONE : Self = Self :: new ( T :: ONE , T :: ZERO ) ;
1179
+ }
1180
+
1181
+ impl < T : Clone + Num + ConstOne + ConstZero > ConstOne for Complex < T > {
1182
+ const ONE : Self = Self :: ONE ;
1183
+ }
1184
+
1167
1185
impl < T : Clone + Num > One for Complex < T > {
1168
1186
#[ inline]
1169
1187
fn one ( ) -> Self {
0 commit comments