Skip to content

Compiler suggestion for attempt to move out of indexed content #38887

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
leonardo-m opened this issue Jan 6, 2017 · 2 comments
Closed

Compiler suggestion for attempt to move out of indexed content #38887

leonardo-m opened this issue Jan 6, 2017 · 2 comments

Comments

@leonardo-m
Copy link

This code:

use std::collections::HashMap;
fn encode2(vals: &[u32], encoding: &HashMap<u32, String>) -> String {
    vals.iter().map(|k| encoding[k]).collect()
}
fn main() {}

It doesn't compile:

error[E0507]: cannot move out of indexed content
 --> ...\test.rs:3:25
  |
3 |     vals.iter().map(|k| encoding[k]).collect()
  |                         ^^^^^^^^^^^ cannot move out of indexed content

    error: aborting due to previous error

Perhaps the compiler could suggest the programmer to add a &* :

vals.iter().map(|k| &*encoding[k]).collect()
@Phlosioneer
Copy link
Contributor

Duplicate of #25507?

@Mark-Simulacrum
Copy link
Member

Yes, I'm going to close in favor of #25507. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants