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
use crateError;
use crateValue;
/// Deserializes a MAML string into any type that implements [`Deserialize`](serde::de::Deserialize).
///
/// This parses the input into a [`Value`] and then deserializes into `T`.
///
/// # Errors
///
/// Returns an [`Error`] on invalid MAML syntax or if the value cannot be
/// deserialized into `T`.
///
/// # Examples
///
/// ```
/// use serde::Deserialize;
///
/// #[derive(Deserialize, Debug, PartialEq)]
/// struct Config {
/// name: String,
/// port: u16,
/// }
///
/// let config: Config = maml::from_str(r#"{name: "app", port: 8080}"#).unwrap();
/// assert_eq!(config, Config { name: "app".into(), port: 8080 });
/// ```
/// Deserializes a [`Value`] into any type that implements [`Deserialize`](serde::de::Deserialize).
///
/// # Errors
///
/// Returns an [`Error`] if the value cannot be deserialized into `T`.
///
/// # Examples
///
/// ```
/// let value = maml::parse("{x: 10, y: 20}").unwrap();
/// let point: std::collections::HashMap<String, i64> = maml::from_value(value).unwrap();
/// assert_eq!(point["x"], 10);
/// ```