ch08
This commit is contained in:
parent
eb9773627e
commit
10b29ad9cb
14 changed files with 164 additions and 0 deletions
13
ch8/ch10/update_old.rs
Normal file
13
ch8/ch10/update_old.rs
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
use std::collections::HashMap;
|
||||
|
||||
fn main() {
|
||||
let text = "hello world wonderful world";
|
||||
let mut map = HashMap::new();
|
||||
|
||||
for word in text.split_whitespace() {
|
||||
let count = map.entry(word).or_insert(0);
|
||||
*count += 1;
|
||||
}
|
||||
|
||||
println!("{map:?}");
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue