entry_put_ext/lib.rs
1/*! Map entry extension for put operations.
2
3*The author of this crate is not good at English.*
4*Forgive me if the document is hard to read.*
5
6This crate extends result type of the `entry` methods of the maps ([`HashMap`]
7and [`BTreeMap`]) by adding an `put` methods. These `put` methods are helper
8method to set a value of an entry and get a reference to it. This makes common
9code about setting and getting shortened a little.
10
11# Examples
12
13```
14use std::collections::HashMap;
15use entry_put_ext::prelude::*;
16
17let mut map = HashMap::from([("X", false)]);
18let x = *map.entry("X").put(true);
19let y = *map.entry("Y").put(true);
20
21assert_eq!(x, map["X"]);
22assert_eq!(y, map["Y"]);
23```
24
25[`BTreeMap`]: std::collections::BTreeMap
26[`HashMap`]: std::collections::HashMap
27*/
28
29#![warn(missing_docs)]
30
31pub mod btree_map;
32pub mod hash_map;
33pub mod prelude;