aboutsummaryrefslogtreecommitdiff
path: root/examples/toml2json.rs
diff options
context:
space:
mode:
Diffstat (limited to 'examples/toml2json.rs')
-rw-r--r--examples/toml2json.rs26
1 files changed, 13 insertions, 13 deletions
diff --git a/examples/toml2json.rs b/examples/toml2json.rs
index 1b90c9f..6e02e8b 100644
--- a/examples/toml2json.rs
+++ b/examples/toml2json.rs
@@ -6,7 +6,7 @@ use std::io;
use std::io::prelude::*;
use serde_json::Value as Json;
-use toml::Value as Toml;
+use milf::Value as Milf;
fn main() {
let mut args = env::args();
@@ -21,27 +21,27 @@ fn main() {
}
match input.parse() {
- Ok(toml) => {
- let json = convert(toml);
+ Ok(milf) => {
+ let json = convert(milf);
println!("{}", serde_json::to_string_pretty(&json).unwrap());
}
- Err(error) => println!("failed to parse TOML: {}", error),
+ Err(error) => println!("failed to parse MILF: {}", error),
}
}
-fn convert(toml: Toml) -> Json {
- match toml {
- Toml::String(s) => Json::String(s),
- Toml::Integer(i) => Json::Number(i.into()),
- Toml::Float(f) => {
+fn convert(milf: Milf) -> Json {
+ match milf {
+ Milf::String(s) => Json::String(s),
+ Milf::Integer(i) => Json::Number(i.into()),
+ Milf::Float(f) => {
let n = serde_json::Number::from_f64(f).expect("float infinite and nan not allowed");
Json::Number(n)
}
- Toml::Boolean(b) => Json::Bool(b),
- Toml::Array(arr) => Json::Array(arr.into_iter().map(convert).collect()),
- Toml::Table(table) => {
+ Milf::Boolean(b) => Json::Bool(b),
+ Milf::Array(arr) => Json::Array(arr.into_iter().map(convert).collect()),
+ Milf::Table(table) => {
Json::Object(table.into_iter().map(|(k, v)| (k, convert(v))).collect())
}
- Toml::Datetime(dt) => Json::String(dt.to_string()),
+ Milf::Datetime(dt) => Json::String(dt.to_string()),
}
}