title: How can I pattern match against an Option<String>?
body: <p>I can straight-forwardly match a <code>String</code> in Rust:</p>
  
  <pre><code>let a = "hello".to_string();
  
  match &amp;a[..] {
      "hello" =&gt; {
          println!("Matches hello");
      }
      _ =&gt; panic!(),
  }
  </code></pre>
  
  <p>If I have an option type, it fails:</p>
  
  <pre><code>match Some(a) {
      Some("hello") =&gt; {
          println!("Matches some hello");
      }
      _ =&gt; panic!(),
  }
  </code></pre>
  
  <p>because the types don't match:</p>
  
  <pre class="lang-none prettyprint-override"><code>error[E0308]: mismatched types
   --&gt; src/main.rs:5:14
    |
  5 |         Some("hello") =&gt; {
    |              ^^^^^^^ expected struct `std::string::String`, found reference
    |
    = note: expected type `std::string::String`
               found type `&amp;'static str`
  </code></pre>
  
  <p>I can't do the <code>[..]</code> trick because we have an <code>Option</code>. The best that
  I have come up with so far is:</p>
  
  <pre><code>match Some(a) {
      Some(b) =&gt; match (&amp;b[..]) {
          "hello" =&gt; {
              println!("Matches some, some hello");
          }
          _ =&gt; panic!(),
      },
      None =&gt; panic!(),
  }
  </code></pre>
  
  <p>which works but is terrible for its verbosity.</p>
  
  <p>In this case, my code is just an example. I do not control the creation of either the <code>String</code> or the <code>Some(String)</code> — so I can't change this type in reality as I could do in my example.</p>
  
  <p>Any other options?</p>