Created
October 18, 2022 16:40
-
-
Save kishansagathiya/2611af8a4e4a75ba5f0c30699bba0339 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let mut btree_map: BTreeMap<String, User> = BTreeMap::new(); | |
match btree_map.entry("string1".to_string()) { | |
Entry::Vacant(entry) => { | |
entry.insert(User{ | |
active: true, | |
username: "lorem".to_string(), | |
email: "lorem@ipsum.org".to_string(), | |
sign_in_count: 1, | |
}); | |
() | |
}, | |
Entry::Occupied(_) => (), | |
} | |
match btree_map.entry("string2".to_string()) { | |
Entry::Vacant(entry) => { | |
entry.insert(User{ | |
active: false, | |
username: "john".to_string(), | |
email: "jack@gmail.com".to_string(), | |
sign_in_count: 73, | |
}); | |
() | |
}, | |
Entry::Occupied(_) => (), | |
} | |
println!("{:?}", btree_map.encode()); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment