#config-toml #file #named

get_config

A simple function to get config from a file

2 releases

0.1.1 Mar 19, 2023
0.1.0 Mar 16, 2023

#44 in #config-toml

39 downloads per month

MIT license

4KB
54 lines

get_config

pub fn main() {
    // There should be either:
    // - a file named `config.toml` in the current directory;
    // - a path passed to `std::env::args().nth(1)`.
    let config: Config = get_config().unwrap();
    println!("{:?}", config);
}
// `Deserialize` is required by `cargo add serde --features derive`
#[derive(Debug, Clone, PartialEq, Eq, Hash, Deserialize)]
struct Config {
    hello: String,
}

Dependencies

~0.6–1.2MB
~27K SLoC