//! An example showing off the usage of `Deserialize` to automatically decode //! TOML into a Rust `struct`
#![deny(warnings)] #![allow(dead_code)]
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. #[derive(Debug, Deserialize)] struct Config {
global_string: Option<String>,
global_integer: Option<u64>,
server: Option<ServerConfig>,
peers: Option<Vec<PeerConfig>>,
}
/// Sub-structs are decoded from tables, so this will decode from the `[server]` /// table. /// /// Again, each field is optional, meaning they don't have to be present. #[derive(Debug, Deserialize)] struct ServerConfig {
ip: Option<String>,
port: Option<u64>,
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.