entry_put_ext
Map entry extension for put operations.
The author of this crate is not good at English.
Forgive me if the document is hard to read.
What is this?
This crate extends result type of the entry methods of the maps (HashMap
and BTreeMap) by adding an put methods. These put methods are helper
method to set a value of an entry and get a reference to it. This makes
common code about setting and getting shortened a little.
use HashMap;
use *;
let mut map = from;
let x = *map.entry.put;
let y = *map.entry.put;
assert_eq!;
assert_eq!;
Other options
Without this crate.
insert and get (Simple, but little slow and not one-liner).
use HashMap;
let mut map = from;
map.insert;
map.insert;
let x = *map.get.unwrap;
let y = *map.get.unwrap;
assert_eq!;
assert_eq!;
and_modify and or_insert (required Copy trait for value type).
use HashMap;
let mut map = from;
let = ;
let x = *map.entry.and_modify.or_insert;
let y = *map.entry.and_modify.or_insert;
assert_eq!;
assert_eq!;
Versions
See CHANGELOG.