title: Is there a way to write to a memory buffer using std::io::Write without re-allocation?
body: <p>Is there a way to use <code>std::io::Write</code> to write a stream directly to memory, without either pre-allocating the final at the outset, or potentially re-allocating the entire array while writing?</p>
  
  <p>While <code>Vec</code> implements <code>Write</code>, this requires contiguous memory and I assume may re-allocate as with regular vector resizing.</p>
  
  <p>Does Rust's <code>stdlib</code> support something like this, or would it need to be implemented?</p>
  
  <hr>
  
  <p>I want to write to memory which has the potential to go into multiple GiB. It's possible the memory is fragmented and it's possible that a contiguous region of the size I want isn't available. Instead, it's quite efficient to allocate many chunks (probably fixed power-of-2 size), and allocate more chunks as they're needed.</p>
  
  <p>Once finished you could read the data back, compress the chunks in memory, cache some to disk, binary-diff with previous writes to de-duplicate chunks... etc.</p>