This commit is contained in:
e2hang
2025-10-05 23:51:24 +08:00
parent 1f9543c16c
commit 23f17bfc2c
113 changed files with 1236 additions and 0 deletions

26
Common-Use/hashmap.rs Normal file
View 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"),
}
}