title: Why isn't it possible to compare a borrowed integer to a literal integer?
body: <p>I want to get the elements in an array where a condition is true. For example. I would like all indices where the array elements are 0:</p>
  
  <pre><code>fn main() {
      let lim = 10;
      let mut sieve = vec![0; lim + 1];
      sieve[1] = 1;
      println!(
          "{:?}",
          sieve
              .iter()
              .enumerate()
              .filter(|&amp;(_, c)| c != 0)
              .map(|(i, _)| i)
              .collect::&lt;Vec&lt;usize&gt;&gt;()
      );
  }
  </code></pre>
  
  <p>But this is a compile error:</p>
  
  <pre class="lang-none prettyprint-override"><code>error[E0277]: can't compare `&amp;{integer}` with `{integer}`
    --&gt; src/main.rs:10:33
     |
  10 |             .filter(|&amp;(_, c)| c != 0)
     |                                 ^^ no implementation for `&amp;{integer} == {integer}`
     |
     = help: the trait `std::cmp::PartialEq&lt;{integer}&gt;` is not implemented for `&amp;{integer}`
  </code></pre>
  
  <p>When I use <code>c.clone() != 0</code> it works.</p>
  
  <p>If I understand the error message correctly, Rust complains that it can't compare a borrow to an integer with an integer. I don't see why it shouldn't be possible.</p>