title: What is an alternative for conditional evaluation like if or match in a Rust const function?
body: <p>I have code which reads a config.toml file based on the environment name and provides all the config settings to the entire project.</p>
  <pre><code>const fn get_conf() -&gt; toml::Value {
      let file_name = match env::var(&quot;ENVIRONMENT&quot;) {
          Ok(val) =&gt; val.to_lowercase(),
          Err(_e) =&gt; &quot;development&quot;.to_lowercase(),
      };
  
      let content = fs::read_to_string(format!(&quot;conf/{}.toml&quot;, file_name)).unwrap();
      let conf: Value = toml::from_str(content.as_str()).unwrap();
  
      conf
  }
  
  static mut CONFIG: toml::Value = get_conf();
  </code></pre>
  <p>I get an error:</p>
  <pre class="lang-none prettyprint-override"><code>error[E0658]: `match` is not allowed in a `const fn`
   --&gt; src/lib.rs:2:21
    |
  2 |       let file_name = match env::var(&quot;ENVIRONMENT&quot;) {
    |  _____________________^
  3 | |         Ok(val) =&gt; val.to_lowercase(),
  4 | |         Err(_e) =&gt; &quot;development&quot;.to_lowercase(),
  5 | |     };
    | |_____^
    |
    = note: see issue #49146 &lt;https://github.com/rust-lang/rust/issues/49146&gt; for more information
  </code></pre>
  <p>This is solved in Rust nightly, but I don't want to use a nightly build for production. Is there any workaround for using a match or if condition in a const function?</p>