toml_example/
traits.rs

1use std::fs::File;
2use std::io::prelude::*;
3use std::path::Path;
4
5pub trait TomlExample {
6    /// structure to toml example
7    fn toml_example() -> String;
8    fn toml_example_with_prefix(label: &str, prefix: &str) -> String;
9    fn to_toml_example<P: AsRef<Path>>(file_name: P) -> std::io::Result<()> {
10        let mut file = File::create(file_name)?;
11        file.write_all(Self::toml_example().as_bytes())?;
12        Ok(())
13    }
14}