std::io::mem: add a with_capacity constructor to MemWriter.

This allows one to reduce the number of reallocs of the internal buffer
if one has an approximate idea of the size of the final output.
auto merge of #10737 : huonw/rust/with-cap, r=alexcrichton

This allows one to reduce the number of reallocs of the internal buffer
if one has an approximate idea of the size of the final output.