Why do lifetimes differ when a function is called in a closure vs. being called directly in Rust? : <p>In the following code example:</p>

<pre><code>fn default_values() -&gt; &amp;'static [u32] {
    static VALUES: [u32; 3] = [1, 2, 3];
    &amp;VALUES
}

fn main() {
    let values: [u32; 3] = [4, 5, 6];
    let optional_values: Option&lt;&amp;[u32]&gt; = Some(&amp;values);

    // this compiles and runs fine 
    let _v = optional_values.unwrap_or_else(|| default_values());

    // this fails to compile
    let _v = optional_values.unwrap_or_else(default_values);
}
</code></pre>

<p>the last statement fails to compile with:</p>

<pre><code>error[E0597]: `values` does not live long enough
  --&gt; src/main.rs:8:49
   |
8  |     let optional_values: Option&lt;&amp;[u32]&gt; = Some(&amp;values);
   |                                                 ^^^^^^ borrowed value does not live long enough
...
12 | }
   | - borrowed value only lives until here
   |
   = note: borrowed value must be valid for the static lifetime...
</code></pre>

<p>I'm wondering:</p>

<ol>
<li>what's happening that causes the difference in behaviour between the last two statements</li>
<li>whether the first <code>unwrap_or_else(|| default_values())</code> is the correct way of handling this, or whether there's a better pattern</li>
</ol>
