Skip to content

unresolved import: could not find hashmap in std. #15082

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
adnelson opened this issue Jun 21, 2014 · 3 comments
Closed

unresolved import: could not find hashmap in std. #15082

adnelson opened this issue Jun 21, 2014 · 3 comments

Comments

@adnelson
Copy link

I'm a Rust beginner trying to write some code which uses a HashMap.

As per this documentation, I have this line:

use std::hashmap::HashMap;

And I get this error message when trying to compile:

$ rustc -v
rustc 0.11.0-pre (0ee6a8e 2014-06-09 23:41:53 -0700)
host: x86_64-apple-darwin
$ rustc foo.rs
foo.rs:1:5: 1:26 error: unresolved import: could not find `hashmap` in `std`.
foo.rs:1 use std::hashmap::HashMap;
            ^~~~~~~~~~~~~~~~~~~~~
foo.rs:1:5: 1:26 error: failed to resolve import `std::hashmap::HashMap`
foo.rs:1 use std::hashmap::HashMap;
            ^~~~~~~~~~~~~~~~~~~~~
error: aborting due to 2 previous errors

I'm really struggling to find how to solve this error; I don't really know about rust's package management system, I don't know how to browse what I have or to install something that I don't have, and reading guides is frustrating because they always seem to be out of date. Can anyone help me with this? How do I get a hash map in rust?

@adnelson
Copy link
Author

The fix was to use the import statement use std::collections::hashmap::HashMap;.

@homeworkprod
Copy link

For the record, because I (being a Rust beginner) had trouble importing HashMap as well, and I came across this issue which helped me to find the solution:

On Rust 0.10, this is what works for me:

extern crate collections;
use collections::hashmap::HashMap;

@huonw
Copy link
Member

huonw commented Jun 28, 2014

The fix was to use the import statement use std::collections::hashmap::HashMap;.

FWIW, it's reexported as std::collections::HashMap.

bors added a commit to rust-lang-ci/rust that referenced this issue Jul 17, 2023
Use `ArgumentV1` instead of `Argument`

Now that the choice is between supporting stable and supporting nothing, let's support stable.

cc rust-lang#15082
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