title: Rust use of moved value
body: <p>When using below function:</p>
  
  <pre><code>fn factors(number: &amp;BigInt) -&gt; Vec&lt;BigInt&gt; {
      let mut n = number.clone();
      let mut i: BigInt = ToBigInt::to_bigint(&amp;2).unwrap();
      let mut factors = Vec::&lt;BigInt&gt;::new();
  
      while i * i &lt;= n {
          if (n % i) == ToBigInt::to_bigint(&amp;1).unwrap() {
              i = i + ToBigInt::to_bigint(&amp;1).unwrap();
          }
          else {
              n = n/i as BigInt;
              factors.push(i);
          }
          i = i + ToBigInt::to_bigint(&amp;1).unwrap();
      }
      if n &gt; i {
          factors.push(n);
      }
      factors
  }
  </code></pre>
  
  <p>I get moved value errors for literally every time <code>i</code> or <code>n</code> is used, starting from the line with <code>while</code>, also in the <code>if</code>. I have read about borrowing, which I understand decently, but this thing I don't understand.
  I am not "copying" the value at all, so I don't see anywhere were I could lose ownership of the variables.</p>