title: Understanding type inference
body: <p>I believe I am having a problem with both the data type and ownership of <code>iter</code>. It is first declared inside the <code>for</code> loop expression. I believe Rust infers that <code>iter</code> is of type <code>u16</code> because it is being used inside of my computation on line 4.</p>
  
  <pre class="lang-rust prettyprint-override"><code>  1     let mut numbers: [Option&lt;u16&gt;; 5];                                          
    2     for iter in 0..5 {                                           
    3         let number_to_add: u16 = {  // `iter` moves to inner scope                                            
    4             ((iter * 5) + 2) / (4 * 16)  // Infers `iter: u16`                                 
    5         };                                                                   
    6                                                                                 
    7         numbers[iter] = Some(number_to_add);  // Expects `iter: usize`                 
    8     }      
  </code></pre>
  
  <p>I am receiving the following error:</p>
  
  <pre><code>error[E0277]: the type `[std::option::Option&lt;u16&gt;]` cannot be indexed by `u16`
    --&gt; exercises/option/option1.rs:3:9
     |
  7  |         numbers[iter] = Some(number_to_add);
     |         ^^^^^^^^^^^^^ slice indices are of type `usize` or ranges of `usize`
  </code></pre>
  
  <ul>
  <li>I tried casting <code>iter</code> as <code>u16</code> inside the computation in line 4, but still having issues.</li>
  </ul>
  
  <p>Where is my misconception? </p>