1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157
|
error[E0382]: use of moved value: `vec`
--> $DIR/recreating-value-in-loop-condition.rs:6:33
|
LL | let vec = vec!["one", "two", "three"];
| --- move occurs because `vec` has type `Vec<&str>`, which does not implement the `Copy` trait
LL | while let Some(item) = iter(vec).next() {
| ----------------------------^^^--------
| | |
| | value moved here, in previous iteration of loop
| inside of this loop
|
note: consider changing this parameter type in function `iter` to borrow instead if owning the value isn't necessary
--> $DIR/recreating-value-in-loop-condition.rs:1:17
|
LL | fn iter<T>(vec: Vec<T>) -> impl Iterator<Item = T> {
| ---- ^^^^^^ this parameter takes ownership of the value
| |
| in this function
help: consider moving the expression out of the loop so it is only moved once
|
LL ~ let mut value = iter(vec);
LL ~ while let Some(item) = value.next() {
|
error[E0382]: use of moved value: `vec`
--> $DIR/recreating-value-in-loop-condition.rs:15:31
|
LL | let vec = vec!["one", "two", "three"];
| --- move occurs because `vec` has type `Vec<&str>`, which does not implement the `Copy` trait
LL | loop {
| ---- inside of this loop
LL |
LL | let Some(item) = iter(vec).next() else {
| ^^^ value moved here, in previous iteration of loop
|
note: consider changing this parameter type in function `iter` to borrow instead if owning the value isn't necessary
--> $DIR/recreating-value-in-loop-condition.rs:1:17
|
LL | fn iter<T>(vec: Vec<T>) -> impl Iterator<Item = T> {
| ---- ^^^^^^ this parameter takes ownership of the value
| |
| in this function
help: consider moving the expression out of the loop so it is only moved once
|
LL ~ let mut value = iter(vec);
LL ~ loop {
LL |
LL ~ let Some(item) = value.next() else {
|
error[E0382]: use of moved value: `vec`
--> $DIR/recreating-value-in-loop-condition.rs:25:25
|
LL | let vec = vec!["one", "two", "three"];
| --- move occurs because `vec` has type `Vec<&str>`, which does not implement the `Copy` trait
LL | loop {
| ---- inside of this loop
LL |
LL | let item = iter(vec).next();
| ^^^ value moved here, in previous iteration of loop
|
note: consider changing this parameter type in function `iter` to borrow instead if owning the value isn't necessary
--> $DIR/recreating-value-in-loop-condition.rs:1:17
|
LL | fn iter<T>(vec: Vec<T>) -> impl Iterator<Item = T> {
| ---- ^^^^^^ this parameter takes ownership of the value
| |
| in this function
help: consider moving the expression out of the loop so it is only moved once
|
LL ~ let mut value = iter(vec);
LL ~ loop {
LL |
LL ~ let item = value.next();
|
help: consider cloning the value if the performance cost is acceptable
|
LL | let item = iter(vec.clone()).next();
| ++++++++
error[E0382]: use of moved value: `vec`
--> $DIR/recreating-value-in-loop-condition.rs:37:34
|
LL | let vec = vec!["one", "two", "three"];
| --- move occurs because `vec` has type `Vec<&str>`, which does not implement the `Copy` trait
LL | loop {
| ---- inside of this loop
LL |
LL | if let Some(item) = iter(vec).next() {
| ^^^ value moved here, in previous iteration of loop
|
note: consider changing this parameter type in function `iter` to borrow instead if owning the value isn't necessary
--> $DIR/recreating-value-in-loop-condition.rs:1:17
|
LL | fn iter<T>(vec: Vec<T>) -> impl Iterator<Item = T> {
| ---- ^^^^^^ this parameter takes ownership of the value
| |
| in this function
help: consider moving the expression out of the loop so it is only moved once
|
LL ~ let mut value = iter(vec);
LL ~ loop {
LL |
LL ~ if let Some(item) = value.next() {
|
error[E0382]: use of moved value: `vec`
--> $DIR/recreating-value-in-loop-condition.rs:50:46
|
LL | let vec = vec!["one", "two", "three"];
| --- move occurs because `vec` has type `Vec<&str>`, which does not implement the `Copy` trait
LL | loop {
| ---- inside of this loop
LL |
LL | loop {
| ---- inside of this loop
LL | loop {
| ---- inside of this loop
LL | if let Some(item) = iter(vec).next() {
| ^^^ value moved here, in previous iteration of loop
|
note: consider changing this parameter type in function `iter` to borrow instead if owning the value isn't necessary
--> $DIR/recreating-value-in-loop-condition.rs:1:17
|
LL | fn iter<T>(vec: Vec<T>) -> impl Iterator<Item = T> {
| ---- ^^^^^^ this parameter takes ownership of the value
| |
| in this function
note: verify that your loop breaking logic is correct
--> $DIR/recreating-value-in-loop-condition.rs:52:25
|
LL | loop {
| ----
LL | let vec = vec!["one", "two", "three"];
LL | loop {
| ----
LL |
LL | loop {
| ----
LL | loop {
| ----
...
LL | break;
| ^^^^^ this `break` exits the loop at line 49
help: consider moving the expression out of the loop so it is only moved once
|
LL ~ let mut value = iter(vec);
LL ~ loop {
LL |
LL | loop {
LL | loop {
LL ~ if let Some(item) = value.next() {
|
error: aborting due to 5 previous errors
For more information about this error, try `rustc --explain E0382`.
|