rust-cli / rust-cli/config-rs

Sub prefixes duplication.

Open
#337 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Rust
Stars
3.2k
Forks
265
Avg merge
2h 42m
Merged PRs (30d)
4

Description

Greetings!

Any way to use prefix which contains different sub prefix without duplication?
What I mean:

use config::{Config, Environment};

fn main() {
    std::env::set_var("FOO_BAR_FIRST", "1");
    std::env::set_var("FOO_SECOND", "2");

    let conf = Config::builder()
        .add_source(Environment::with_prefix("FOO_BAR").separator("_"))
        .add_source(Environment::with_prefix("FOO").separator("_"))
        .build()
        .unwrap();

    println!("{}", conf.cache);
}

Got: { first => 1, bar => { first => 1, }, second => 2, }.
Expected: { first => 1, second => 2, }.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the Rust example with Environment::with_prefix and the two overlapping prefixes, then trace how environment keys are merged into Config. Done means the resulting cache contains first and second without the duplicated nested bar entry, while preserving both environment values.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.