]> git.lizzy.rs Git - rust.git/blobdiff - tests/ui/while_let_on_iterator.fixed
Fix `while_let_on_iterator`
[rust.git] / tests / ui / while_let_on_iterator.fixed
index 52e80ceee83cf31439c07cfff967fc46a03e09fd..52c70ced2bd88cefb91025fe708024b612a601be 100644 (file)
@@ -334,6 +334,29 @@ fn issue7249() {
     x();
 }
 
+fn issue7510() {
+    let mut it = 0..10;
+    let it = &mut it;
+    // Needs to reborrow `it` as the binding isn't mutable
+    for x in &mut *it {
+        if x % 2 == 0 {
+            break;
+        }
+    }
+    println!("{}", it.next().unwrap());
+
+    struct S<T>(T);
+    let mut it = 0..10;
+    let it = S(&mut it);
+    // Needs to reborrow `it.0` as the binding isn't mutable
+    for x in &mut *it.0 {
+        if x % 2 == 0 {
+            break;
+        }
+    }
+    println!("{}", it.0.next().unwrap());
+}
+
 fn main() {
     let mut it = 0..20;
     for _ in it {