1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
use HashMap;
/// Creates a new HashMap with the same keys as `map` and values generated
/// by running each key-value pair of `map` through the `mapper` function.
///
/// # Arguments
///
/// * `map` - The HashMap to iterate over.
/// * `mapper` - The function invoked per iteration, taking a key-value pair and returning the mapped value.
///
/// # Returns
///
/// Returns a new HashMap with the mapped values.
///
/// # Examples
///
/// ```
/// use lorust::map_values;
/// use std::collections::HashMap;
///
/// let mut users = HashMap::new();
/// users.insert("fred", 40);
/// users.insert("pebbles", 1);
///
/// let result = map_values(&users, |(_, &value)| value * 2);
///
/// assert_eq!(result.get("fred"), Some(&80));
/// assert_eq!(result.get("pebbles"), Some(&2));
/// ```