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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
/// Simple Crate for converting a HashMap<String, String>
/// to a struct.
///
/// Provides one main trait and derive macro,
/// named `Map2Struct`.
///
/// # Example
/// ```
/// use std::collections::HashMap;
/// use map2struct::Map2Struct;
///
/// #[derive(Map2Struct)]
/// struct Person {
/// name: String,
/// age: u32,
/// }
///
/// let mut map = HashMap::new();
/// map.insert("name".to_string(), "John".to_string());
/// map.insert("age".to_string(), "30".to_string());
/// let person = Person::from_map(map).expect("Parsing failed");
/// assert_eq!(person.name, "John");
/// assert_eq!(person.age, 30);
/// ```
///
/// Fields are parsed using the `.parse` method of `String`
/// values.
///
/// The following validations steps are performed:
/// 1) Check if all fields are present
/// 2) Check that no additional fields are present
/// 3) Check type conversions
///
use HashMap;
pub use *;
pub type Result<S> = Result;