title: How do I change a function's qualifiers via conditional compilation?
body: <p>I have a function that is capable of being implemented as a <code>const</code>:</p>
  
  <pre><code>#![feature(const_fn)]
  
  // My crate would have:
  
  const fn very_complicated_logic(a: u8, b: u8) -&gt; u8 {
      a * b
  }
  
  // The caller would have:
  
  const ANSWER: u8 = very_complicated_logic(1, 2);
  
  fn main() {}
  </code></pre>
  
  <p>I'd like to continue to support stable Rust where it's not possible to define such functions. These stable consumers would not be able to use the function in a <code>const</code> or <code>static</code>, but should be able to use the function in other contexts:</p>
  
  <pre><code>// My crate would have:
  
  fn very_complicated_logic(a: u8, b: u8) -&gt; u8 {
      a * b
  }
  
  // The caller would have:    
  
  fn main() {
      let answer: u8 = very_complicated_logic(1, 2);
  }
  </code></pre>
  
  <p>How can I conditionally compile my code so that adventurous users of my crate could enable <code>const fn</code> support, stable users would still be able to use my code, and I don't have to write every function twice?</p>
  
  <p>The same question should apply to the other modifiers of a function, but I'm not sure of concrete cases where these modifiers would change based on some condition:</p>
  
  <ul>
  <li><code>default</code></li>
  <li><code>unsafe</code></li>
  <li><code>extern</code></li>
  <li><code>pub</code> (and other visibility modifiers) </li>
  </ul>