use miniconf::{Leaf, Tree}; use serde::{Deserialize, Serialize}; // Either/Inner/Settings are straight from README.md #[derive(Deserialize, Serialize, Default, Tree)] pub struct Inner { a: Leaf, b: Leaf, } #[derive(Deserialize, Serialize, Default, Tree)] pub enum Either { #[default] Bad, Good, A(Leaf), B(Inner), C([Inner; 2]), } #[derive(Tree, Default)] pub struct Settings { foo: Leaf, enum_: Leaf, struct_: Leaf, array: Leaf<[i32; 2]>, option: Leaf>, #[tree(skip)] #[allow(unused)] skipped: (), struct_tree: Inner, enum_tree: Either, array_tree: [Leaf; 2], array_tree2: [Inner; 2], tuple_tree: (Leaf, Inner), option_tree: Option>, option_tree2: Option, array_option_tree: [Option; 2], } impl Settings { /// Fill some of the Options pub fn enable(&mut self) { self.option_tree = Some(8.into()); self.enum_tree = Either::B(Default::default()); self.option_tree2 = Some(Default::default()); self.array_option_tree[1] = Some(Default::default()); } }