File tree Expand file tree Collapse file tree 3 files changed +30
-2
lines changed Expand file tree Collapse file tree 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 {
104104 impl Sum for $a {
105105 fn sum<I : Iterator <Item =Self >>( iter: I ) -> Self {
106106 iter. fold(
107- 0.0 ,
107+ - 0.0 ,
108108 #[ rustc_inherit_overflow_checks]
109109 |a, b| a + b,
110110 )
@@ -126,7 +126,7 @@ macro_rules! float_sum_product {
126126 impl <' a> Sum <& ' a $a> for $a {
127127 fn sum<I : Iterator <Item =& ' a Self >>( iter: I ) -> Self {
128128 iter. fold(
129- 0.0 ,
129+ - 0.0 ,
130130 #[ rustc_inherit_overflow_checks]
131131 |a, b| a + b,
132132 )
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;
3030mod ops;
3131mod wrapping;
3232
33+ mod float_iter_sum_identity;
3334mod ieee754;
3435mod nan;
3536
You can’t perform that action at this time.
0 commit comments