File tree 3 files changed +30
-2
lines changed
3 files changed +30
-2
lines changed Original file line number Diff line number Diff line change @@ -104,7 +104,7 @@ macro_rules! float_sum_product {
104
104
impl Sum for $a {
105
105
fn sum<I : Iterator <Item =Self >>( iter: I ) -> Self {
106
106
iter. fold(
107
- 0.0 ,
107
+ - 0.0 ,
108
108
#[ rustc_inherit_overflow_checks]
109
109
|a, b| a + b,
110
110
)
@@ -126,7 +126,7 @@ macro_rules! float_sum_product {
126
126
impl <' a> Sum <& ' a $a> for $a {
127
127
fn sum<I : Iterator <Item =& ' a Self >>( iter: I ) -> Self {
128
128
iter. fold(
129
- 0.0 ,
129
+ - 0.0 ,
130
130
#[ rustc_inherit_overflow_checks]
131
131
|a, b| a + b,
132
132
)
Original file line number Diff line number Diff line change
1
+ #[ test]
2
+ fn f32_ref ( ) {
3
+ let x: f32 = -0.0 ;
4
+ let still_x: f32 = [ x] . iter ( ) . sum ( ) ;
5
+ assert_eq ! ( 1. / x, 1. / still_x)
6
+ }
7
+
8
+ #[ test]
9
+ fn f32_own ( ) {
10
+ let x: f32 = -0.0 ;
11
+ let still_x: f32 = [ x] . into_iter ( ) . sum ( ) ;
12
+ assert_eq ! ( 1. / x, 1. / still_x)
13
+ }
14
+
15
+ #[ test]
16
+ fn f64_ref ( ) {
17
+ let x: f64 = -0.0 ;
18
+ let still_x: f64 = [ x] . iter ( ) . sum ( ) ;
19
+ assert_eq ! ( 1. / x, 1. / still_x)
20
+ }
21
+
22
+ #[ test]
23
+ fn f64_own ( ) {
24
+ let x: f64 = -0.0 ;
25
+ let still_x: f64 = [ x] . into_iter ( ) . sum ( ) ;
26
+ assert_eq ! ( 1. / x, 1. / still_x)
27
+ }
Original file line number Diff line number Diff line change @@ -30,6 +30,7 @@ mod int_log;
30
30
mod ops;
31
31
mod wrapping;
32
32
33
+ mod float_iter_sum_identity;
33
34
mod ieee754;
34
35
mod nan;
35
36
You can’t perform that action at this time.
0 commit comments