title: How to match with vector element in Rust?
body: <p>In Rust, matching a value like this works:</p>
  <pre><code>let x = 1;
  
  match x {
      1 =&gt; println!(&quot;one&quot;),
      2 =&gt; println!(&quot;two&quot;),
      _ =&gt; println!(&quot;something else&quot;)
  }
  </code></pre>
  <p>But using values from a vector instead of hard-coded numbers in <code>match</code> doesn't work:</p>
  <pre><code>let x = 1;
  let list = vec![1, 2];
  
  match x {
      list[0] =&gt; println!(&quot;one&quot;),
      list[1] =&gt; println!(&quot;two&quot;),
      _ =&gt; println!(&quot;something else&quot;)
  }
  </code></pre>
  <p>This fails with the message:</p>
  <pre class="lang-none prettyprint-override"><code>error: expected one of `=&gt;`, `@`, `if`, or `|`, found `[`
   --&gt; src/main.rs:6:9
    |
  6 |     list[0] =&gt; println!(&quot;one&quot;),
    |         ^ expected one of `=&gt;`, `@`, `if`, or `|` here
  </code></pre>
  <p>Why doesn't it work?</p>