Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- use std::collections::BTreeMap;
- fn main() {
- let mut map = BTreeMap::new();
- map.insert("key", "value");
- map.insert("key1", "value1");
- map.insert("key2", "value2");
- println!("map: {:?}", map);
- let key = "key1";
- let should_remove = {
- let value = map.get(key);
- value == Some(&"value1")
- };
- if should_remove {
- map.remove(key);
- }
- println!("map: {:?}", map);
- }
Add Comment
Please, Sign In to add comment