title: How to share stream position betwixt functions in Swift?
body: <p>I was surprised by the following playground I created after seeing some unexpected behavior in my code:</p>
  
  <pre><code>import Foundation
  
  let bytes:[UInt8] = [20, 30, 40, 50, 60, 70]
  var stream = bytes.generate()
  
  func consumeTwo(var stream:IndexingGenerator&lt;[UInt8]&gt;) {
      print(stream.next())
      print(stream.next())
  }
  
  consumeTwo(stream) // This prints 20 and 30
  
  print(stream.next()) // This prints 20!? I expected 40!
  </code></pre>
  
  <p>I had thought that marking the <code>stream</code> argument as <code>var</code> to the <code>consumeTwo()</code> function, the stream state/position would be shared/updated as it moved from function to function. But that appears to not be the case.</p>
  
  <p>Does this mean I need to make that an <code>inout</code>? And pass with the ampersand? When does one use the <code>var</code> if that's the case?</p>
  
  <p>More generally... what is the right/idiomatic way to create a stream over a byte array which can be passed from function to function (e.g. a decoder) and preserve the position of the stream as it is passed around?</p>