File tree 3 files changed +19
-2
lines changed
3 files changed +19
-2
lines changed Original file line number Diff line number Diff line change @@ -608,7 +608,8 @@ where
608
608
if A :: MAY_HAVE_SIDE_EFFECT && sz_a > self . len {
609
609
// FIXME(const_trait_impl): replace with `for`
610
610
let mut i = 0 ;
611
- while i < sz_a - self . len {
611
+ let upper_bound = sz_a - self . len ;
612
+ while i < upper_bound {
612
613
// since next_back() may panic we increment the counters beforehand
613
614
// to keep Zip's state in sync with the underlying iterator source
614
615
self . a_len -= 1 ;
@@ -634,7 +635,7 @@ where
634
635
if B :: MAY_HAVE_SIDE_EFFECT && sz_b > self . len {
635
636
// FIXME(const_trait_impl): replace with `for`
636
637
let mut i = 0 ;
637
- while i < sz_a - self . len {
638
+ while i < sz_b - self . len {
638
639
self . b . next_back ( ) ;
639
640
i += 1 ;
640
641
}
Original file line number Diff line number Diff line change @@ -100,3 +100,17 @@ pub fn extend_for_unit() {
100
100
}
101
101
assert_eq ! ( x, 5 ) ;
102
102
}
103
+
104
+ #[ test]
105
+ fn test_const_iter ( ) {
106
+ const X : usize = {
107
+ let mut n = 0 ;
108
+ for a in Some ( 1 ) {
109
+ n = a;
110
+ }
111
+ n
112
+ } ;
113
+
114
+ const _: ( ) = assert ! ( X == 1 ) ;
115
+ assert_eq ! ( 1 , X ) ;
116
+ }
Original file line number Diff line number Diff line change 12
12
#![ feature( const_cell_into_inner) ]
13
13
#![ feature( const_convert) ]
14
14
#![ feature( const_hash) ]
15
+ #![ feature( const_for) ]
15
16
#![ feature( const_heap) ]
17
+ #![ feature( const_iter) ]
16
18
#![ feature( const_maybe_uninit_as_mut_ptr) ]
17
19
#![ feature( const_maybe_uninit_assume_init_read) ]
18
20
#![ feature( const_nonnull_new) ]
You can’t perform that action at this time.
0 commit comments