Crates.io | derive-config |
lib.rs | derive-config |
version | 2.3.0 |
source | src |
created_at | 2024-02-06 04:26:56.036472 |
updated_at | 2024-10-06 23:19:02.319188 |
description | My personal configuration library |
homepage | |
repository | https://github.com/ShayBox/Derive-Config |
max_upload_size | |
id | 1128446 |
size | 4,212 |
My simple configuration library
use derive_config::DeriveTomlConfig;
use serde::{Deserialize, Serialize};
#[derive(Debug, Default, DeriveTomlConfig, Deserialize, Serialize)]
struct ExampleConfig {
foo: String,
}
fn main() {
let mut config = ExampleConfig::load().unwrap_or_default();
println!("{}", config.foo);
config.foo = String::from(if config.foo == "bar" { "baz" } else { "bar" });
config.save().expect("Failed to save");
println!("{}", config.foo);
}