figment2

Crates.iofigment2
lib.rsfigment2
version0.11.4
created_at2025-12-03 12:29:27.937352+00
updated_at2026-01-04 17:32:15.647445+00
descriptionRemaintained fork of figment: A configuration library so con-free, it's unreal.
homepage
repositoryhttps://github.com/lmmx/figment2
max_upload_size
id1963941
size369,044
Louis Maddox (lmmx)

documentation

https://docs.rs/figment2

README

figment2   ci.svg crates.io docs.rs

Remaintained fork of figment

Figment2 is a semi-hierarchical configuration library for Rust so con-free, it's unreal.

use serde::Deserialize;

use figment2::{Figment, providers::{Format, Toml, Json, Env}};

#[derive(Deserialize)]
struct Package {
    name: String,
    authors: Vec<String>,
    publish: Option<bool>,
    // ... and so on ...
}

#[derive(Deserialize)]
struct Config {
    package: Package,
    rustc: Option<String>,
    // ... and so on ...
}

let config: Config = Figment::new()
    .merge(Toml::file("Cargo.toml"))
    .merge(Env::prefixed("CARGO_"))
    .merge(Env::raw().only(&["RUSTC", "RUSTDOC"]))
    .join(Json::file("Cargo.json"))
    .extract()?;

See the documentation for a detailed usage guide and information.

Usage

Add the following to your Cargo.toml, enabling the desired built-in providers:

[dependencies]
figment2 = { version = "0.11", features = ["toml"] }

License

Figment is licensed under either of the following, at your option:

Commit count: 0

cargo fmt