New Rust
This commit is contained in:
26
Common-Use/hashmap.rs
Normal file
26
Common-Use/hashmap.rs
Normal file
@@ -0,0 +1,26 @@
|
||||
use std::collections::HashMap;
|
||||
|
||||
fn thereisnoerror() {
|
||||
let mut map = std::collections::HashMap::new();
|
||||
map.insert("key1", "value1");
|
||||
map.insert("key2", "value2");
|
||||
println!("{:?}", map);
|
||||
}
|
||||
|
||||
fn main(){
|
||||
let mut h = HashMap::new();
|
||||
h.insert(1, "one");
|
||||
h.insert(2, "two");
|
||||
h.insert(3, "three");
|
||||
h.insert(4, "four");
|
||||
h.insert(5, "five");
|
||||
print!("{:?} ", h);
|
||||
//println!("{0}", *h.count(4));
|
||||
let mut a = |y: i64| -> i64 { return 1 + y; };
|
||||
let result = a(3);
|
||||
println!("{}", result);
|
||||
match h.get(&4) {
|
||||
Some(v) => println!("Found: {}", v),
|
||||
None => println!("Not Found"),
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user