You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
error[E0382]: borrow of moved value: `names`
--> src/main.rs:11:29
|
2 | let names = vec!["Bob", "Frank", "Ferris"];
| ----- move occurs because `names` has type `Vec<&str>`, which does not implement the `Copy` trait
3 |
4 | for name in names.into_iter() {
| ----------- `names` moved due to this method call
...
11 | println!("names: {:?}", names);
| ^^^^^ value borrowed here after move
|
note: `into_iter` takes ownership of the receiver `self`, which moves `names`
--> /playground/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/iter/traits/collect.rs:346:18
|
346 | fn into_iter(self) -> Self::IntoIter;
| ^^^^
= note: this error originates in the macro `$crate::format_args_nl` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info)
help: you can `clone` the value and consume it, but this might not be your desired behavior
|
4 | for name in names.clone().into_iter() {
| ++++++++
The text was updated successfully, but these errors were encountered:
The code doesn't compile (not even online):
The text was updated successfully, but these errors were encountered: