提交 287df9e0 编写于 作者: A Alex Crichton

rollup merge of #18329 : sfackler/memwriter-clear

......@@ -22,7 +22,7 @@
use slice::AsSlice;
use vec::Vec;
static BUF_CAPACITY: uint = 128;
const BUF_CAPACITY: uint = 128;
fn combine(seek: SeekStyle, cur: uint, end: uint, offset: i64) -> IoResult<u64> {
// compute offset as signed and clamp to prevent overflow
......@@ -71,7 +71,12 @@ pub fn new() -> MemWriter {
/// the internal buffer.
#[inline]
pub fn with_capacity(n: uint) -> MemWriter {
MemWriter { buf: Vec::with_capacity(n) }
MemWriter::from_vec(Vec::with_capacity(n))
}
/// Create a new `MemWriter` that will append to an existing `Vec`.
#[inline]
pub fn from_vec(buf: Vec<u8>) -> MemWriter {
MemWriter { buf: buf }
}
/// Acquires an immutable reference to the underlying buffer of this
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册