beginnerModules
Use and Import
Import items with use keyword.
Use and Import
Import items with use keyword.
Difficulty
Beginner
Code
rust
use std::collections::{HashMap, HashSet};
use std::io::{self, Write};
fn main() {
let mut map = HashMap::new();
map.insert("key", "value");
let set: HashSet<i32> = vec![1, 2, 3].into_iter().collect();
println!("{:?} {:?}", map, set);
}Explanation
use brings items into scope.
Key Concepts
- Read the code carefully and understand the data flow
- Try modifying the example to see how it changes behavior
- Run this code in the Rust Playground
Related Topics
Browse more examples in the modules category to build a complete understanding of this topic.