Skip to content

rustling有些测试官方代码会报错 #2

@bugparty

Description

@bugparty

评测练习: hashmaps2.rs

error[E0599]: no function or associated item named from_iter found for struct std::collections::HashMap in the current scope
--> /Users/bowmanhan/sources/learning-tools/./exercises/rustlings/exercises/11_hashmaps/hashmaps2.rs:61:18
|
61 | HashMap::from_iter(content)
| ^^^^^^^^^ function or associated item not found in HashMap<_, _, _>
|
note: if you're trying to build a new std::collections::HashMap<_, _, _> consider using one of the following associated functions:
std::collections::HashMap::<K, V>::new
std::collections::HashMap::<K, V>::with_capacity
std::collections::HashMap::<K, V, S>::with_hasher
std::collections::HashMap::<K, V, S>::with_capacity_and_hasher
--> /rustc/6b00bc3880198600130e1cf62b8f8a93494488cc/library/std/src/collections/hash/map.rs:261:5
= help: items from traits can only be used if the trait is in scope
help: trait FromIterator which provides from_iter is implemented but not in scope; perhaps you want to import it
|
56 + use std::iter::FromIterator;
|

error: aborting due to 1 previous error

For more information about this error, try rustc --explain E0599.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions