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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
use Path;
use crate::;
use ;
/// Deserialize items from the text of the Munyo language.
///
/// # Example
/// ```
/// #[derive(serde::Deserialize, Debug, PartialEq)]
/// enum Enum{
/// Foo,
/// }
/// fn main() -> munyo::Result<()>{
/// let v : Vec<Enum> = munyo::from_str("Foo")?;
/// assert_eq!(&v[0], &Enum::Foo);
/// Ok(())
/// }
/// ```
/// Deserialize items from the path of the source file of the Munyo language.
///
/// # Example
/// ```
/// #[derive(serde::Deserialize, Debug, PartialEq)]
/// enum Enum{
/// Foo,
/// }
/// fn main() -> munyo::Result<()>{
/// let text = "Foo";
/// // Write the text to a file and get the path.
/// # let file = munyo::temp(text)?;
/// # let path = file.path();
/// let v : Vec<Enum> = munyo::from_file(path)?;
/// assert_eq!(&v[0], &Enum::Foo);
/// Ok(())
/// }
/// ```
/// Deserialize items from the text and the path of the source file of the Munyo language
///
/// The path is only used for the error messages. See [from_str] for the usage.
/// Serialize items to the text of Munyo language
///
/// # Example
/// ```
/// #[derive(serde::Serialize)]
/// enum Enum{
/// Item(usize, String, f64, Vec<Enum>)
/// }
/// fn main() -> munyo::Result<()>{
/// let item = Enum::Item(5, "s".to_string(), 1.1, vec![
/// Enum::Item(4,"t".to_string(), 3.4, vec![])
/// ]);
/// let items = vec![item];
/// let text = munyo::to_string(&items)?;
/// assert_eq!(&text,
/// r"Item 5 s 1.1
/// Item 4 t 3.4
/// ");
/// Ok(())
/// }
/// ```