title: How can I correct "cannot infer an appropriate lifetime" without editing function signature?
body: <p>Background: I'm creating an iterator that returns a reference to a slice <code>&amp;[T]</code>, but the data vector needs to remain immutable. The iterator <strong>cannot</strong> modify the original data, but must return the same slice pointer repeatedly after it has modified it. I've considered having my iterator own a <code>Vec&lt;T&gt;</code>, but I would like to avoid that (and it didn't seem to work). I avoid allocations since I plan to use it mostly in realtime audio and allocations could potentially block. Code: </p>
  
  <pre><code>pub struct Windower&lt;'a, 'b, T: 'a + 'b&gt; {
      window_type: WindowType,
      hop_size: usize,
      bin_size: usize,
      current_index: usize,
      data: &amp;'a [T],
      out_data: &amp;'b mut [T]
  }
  
  impl&lt;'a, 'b, T: Float + FromPrimitive&gt; Iterator for Windower&lt;'a, 'b, T&gt; {
      type Item = &amp;'b [T];
  
      fn next(&amp;mut self) -&gt; Option&lt;Self::Item&gt; {
          if self.current_index &lt; (self.len() - 1) {
              let start = self.current_index * self.hop_size;
              let end = start + self.bin_size;
              self.current_index += 1;
              let window = self.window();
              let data_iter = self.data[start..end].iter();
  
              for &amp;mut v in self.out_data {
                  let val: T = window.next().unwrap() * 
                       *data_iter.next().unwrap();
                  v = val;
              }
  
              Some(self.out_data)
          } else {
              None
          }
      }
  }
  </code></pre>
  
  <p>Returns the error:</p>
  
  <pre><code>src/waves.rs:160:18: 160:31 error: cannot infer an appropriate lifetime for automatic coercion due to conflicting requirements [E0495]
  src/waves.rs:160             Some(self.out_data)
                                    ^~~~~~~~~~~~~
  src/waves.rs:146:5: 164:6 help: consider using an explicit lifetime parameter as shown: fn next(&amp;'b mut self) -&gt; Option&lt;Self::Item&gt;
  </code></pre>
  
  <p>I cannot figure out how to fix this. I can't make the change suggested, because the trait implementation for Iterator does not have an explicit lifetime parameter.</p>