expression

Track configuration source without exposing secrets

Keep source metadata next to the selected value to explain surprising configuration. Log only the source and explicitly safe fields. Here the configuration is a non-secret report limit; no environment dump is necessary. Fixture: Expected stdout (not executed): limit=5; source=environment Expected stderr: (empty) Expected exit: 0 Common mistake: Printing tokens, passwords or full config debug representations to troubleshoot precedence.

Formal Syntax & Structure

rust syntaxrust
(value, source_label)

Working Example

Example Snippetrust
fn main() {    fn choose(cli: Option<u16>, env: Option<u16>, file: Option<u16>) -> (u16, &'static str) {        if let Some(v) = cli { (v, "cli") }        else if let Some(v) = env { (v, "environment") }        else if let Some(v) = file { (v, "file") }        else { (10, "default") }    }    let (limit, source) = choose(None, Some(5), Some(9));    println!("limit={limit}; source={source}");}
Rust Reference