<!--
title: Standardize configuration value handling
domain: runtimes
topic: Configurations
language: Rust
source: rust-lang/rust
updated: 2025-07-22
url: https://awesomereviewers.com/reviewers/rust-standardize-configuration-value-handling/
-->

Implement robust and type-safe configuration handling to avoid fragile hardcoding and improve maintainability. Key guidelines:

1. Use type-safe structures for passing configuration between processes instead of raw strings
2. Avoid hardcoding environment paths or configuration values
3. Use environment variables through a centralized configuration system
4. Validate configuration values at startup

Example of improved configuration handling:

```rust
// Instead of this:
let docs = env::args_os().nth(1).expect("doc path should be first argument");
let docs = env::current_dir().unwrap().join(docs);

// Do this:
#[derive(Parser)]
struct Config {
    docs: PathBuf,
    #[clap(long)]
    link_targets_dir: Vec<PathBuf>,
}

let config = Config::parse();
let docs = config.docs.canonicalize()?;
```

This approach:
- Makes configuration requirements explicit
- Provides type safety
- Centralizes configuration handling
- Makes testing and validation easier
- Reduces fragility from hardcoded values
