diff options
author | Alex Crichton <alex@alexcrichton.com> | 2016-10-02 23:26:51 -0700 |
---|---|---|
committer | Alex Crichton <alex@alexcrichton.com> | 2016-10-02 23:26:51 -0700 |
commit | 80c0cfd2f0a4decc6c147729225888af3c7152d0 (patch) | |
tree | dfbc7dfa9f1ea2b6c9f0ff312a8f7b1b958d791c /examples/struct.rs | |
parent | 680e5dc0701e198e32b8ea5a192e84c01e6a16de (diff) | |
download | milf-rs-80c0cfd2f0a4decc6c147729225888af3c7152d0.tar.gz milf-rs-80c0cfd2f0a4decc6c147729225888af3c7152d0.zip |
Touch up the `decode` example
Diffstat (limited to 'examples/struct.rs')
-rw-r--r-- | examples/struct.rs | 51 |
1 files changed, 0 insertions, 51 deletions
diff --git a/examples/struct.rs b/examples/struct.rs deleted file mode 100644 index 52b2eb7..0000000 --- a/examples/struct.rs +++ /dev/null @@ -1,51 +0,0 @@ -#![deny(warnings)] -extern crate toml; -extern crate rustc_serialize; - -use rustc_serialize::Decodable; - -#[derive(Debug,RustcDecodable)] -struct Config { - global_string: Option<String>, - global_integer: Option<u64>, - server: Option<ServerConfig>, - peers: Option<Vec<PeerConfig>>, -} - -#[derive(Debug,RustcDecodable)] -struct ServerConfig { - ip: Option<String>, - port: Option<u64>, -} - -#[derive(Debug,RustcDecodable)] -struct PeerConfig { - ip: Option<String>, - port: Option<u64>, -} - -fn main() { - let toml_str = r#" - global_string = "test" - global_integer = 5 - - [server] - ip = "127.0.0.1" - port = 80 - - [[peers]] - ip = "127.0.0.1" - port = 8080 - - [[peers]] - ip = "127.0.0.1" - port = 8081 - "#; - - let toml = toml::Parser::new(&toml_str).parse().unwrap(); - - let mut decoder = toml::Decoder::new(toml::Value::Table(toml)); - let decoded = Config::decode(&mut decoder).unwrap(); - - println!("{:?}", decoded); -} |