title: How can I use multi-line match clauses that return values in rust?
body: <p>For a toy example, say I'd like to make a cache for files on disk and log its output. Here's what I hoped would work:</p>
  <pre><code>struct Cache {
    data: HashMap&lt;String, String&gt;
  }
  
  impl Cache {
    fn load(&amp;mut self, filename: &amp;str) -&gt; String {
      let result = match self.data.get(filename) {
        Some(s) =&gt; s.clone(),
        None =&gt; {
          let s = fs::read_to_string(filename).expect(&quot;couldn't read&quot;);
          self.data.insert(String::from(filename), s.clone());
          return s;
        }
      };
      println!(&quot;my result: {}&quot;, result);
      return result;
    }
  }
  </code></pre>
  <p>But the <code>None =&gt; {...}</code> clause isn't executed like its own function, so its <code>return</code> exits the whole <code>load</code> function. I tried a couple different ways, but couldn't get multi-line match clauses to return a value. Is there any way to get this type of <code>match</code> working in rust?</p>
  <p>rust version: 1.50.0
  language edition: 2018</p>