aboutsummaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorMelody Horn <melody@boringcactus.com>2021-03-21 14:10:24 -0600
committerMelody Horn <melody@boringcactus.com>2021-03-21 14:10:24 -0600
commit7bbbfd046324363c8db1fb15d39aeb02fe7331b5 (patch)
treea416bb991c23e083d0b5816dfc8b00cd1aceda78 /examples
parentb1417006df376e6c406bff43740dd11aa7ef744e (diff)
downloadmilf-rs-main.tar.gz
milf-rs-main.zip
hilarious and original jokeHEADmain
Diffstat (limited to 'examples')
-rw-r--r--examples/decode.rs8
-rw-r--r--examples/enum_external.rs6
-rw-r--r--examples/toml2json.rs26
3 files changed, 20 insertions, 20 deletions
diff --git a/examples/decode.rs b/examples/decode.rs
index b5d6a99..63fb315 100644
--- a/examples/decode.rs
+++ b/examples/decode.rs
@@ -1,12 +1,12 @@
//! An example showing off the usage of `Deserialize` to automatically decode
-//! TOML into a Rust `struct`
+//! MILF into a Rust `struct`
#![deny(warnings)]
use serde_derive::Deserialize;
/// This is what we're going to decode into. Each field is optional, meaning
-/// that it doesn't have to be present in TOML.
+/// that it doesn't have to be present in MILF.
#[derive(Debug, Deserialize)]
struct Config {
global_string: Option<String>,
@@ -32,7 +32,7 @@ struct PeerConfig {
}
fn main() {
- let toml_str = r#"
+ let milf_str = r#"
global_string = "test"
global_integer = 5
@@ -48,6 +48,6 @@ fn main() {
ip = "127.0.0.1"
"#;
- let decoded: Config = toml::from_str(toml_str).unwrap();
+ let decoded: Config = milf::from_str(milf_str).unwrap();
println!("{:#?}", decoded);
}
diff --git a/examples/enum_external.rs b/examples/enum_external.rs
index a7dd84a..4cddabb 100644
--- a/examples/enum_external.rs
+++ b/examples/enum_external.rs
@@ -1,5 +1,5 @@
//! An example showing off the usage of `Deserialize` to automatically decode
-//! TOML into a Rust `struct`, with enums.
+//! MILF into a Rust `struct`, with enums.
#![deny(warnings)]
@@ -26,7 +26,7 @@ enum MyEnum {
}
fn main() {
- let toml_str = r#"
+ let milf_str = r#"
plain = "Plain"
plain_table = { Plain = {} }
tuple = { Tuple = { 0 = 123, 1 = true } }
@@ -39,6 +39,6 @@ fn main() {
{ Struct = { value = 123 } }
]"#;
- let decoded: Config = toml::from_str(toml_str).unwrap();
+ let decoded: Config = milf::from_str(milf_str).unwrap();
println!("{:#?}", decoded);
}
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()),
}
}