use std::env;
      use std::fs;
      use std::io::Error;
      fn main() -> Result<(), Error> {
        // read `config_path` from the environment variable `CONFIG`.
        // If `CONFIG` isn't set, fall back to a default config path.
        let config_path = env::var("CONFIG")
        let config: String = fs::read_to_string(config_path)?;
        println!("Config: {}", config);

      Rust language logo
      Read environment variable

      Codiga's Rust Recipes

      read or set fallback


        Add Comment

        Log in to add a comment

        Codiga - All rights reserved 2022.