We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 80e5fe1 commit bed5a7dCopy full SHA for bed5a7d
src/libstd/io/mem.rs
@@ -22,7 +22,7 @@ use slice;
22
use slice::AsSlice;
23
use vec::Vec;
24
25
-static BUF_CAPACITY: uint = 128;
+const BUF_CAPACITY: uint = 128;
26
27
fn combine(seek: SeekStyle, cur: uint, end: uint, offset: i64) -> IoResult<u64> {
28
// compute offset as signed and clamp to prevent overflow
@@ -71,7 +71,12 @@ impl MemWriter {
71
/// the internal buffer.
72
#[inline]
73
pub fn with_capacity(n: uint) -> MemWriter {
74
- MemWriter { buf: Vec::with_capacity(n) }
+ MemWriter::from_vec(Vec::with_capacity(n))
75
+ }
76
+ /// Create a new `MemWriter` that will append to an existing `Vec`.
77
+ #[inline]
78
+ pub fn from_vec(buf: Vec<u8>) -> MemWriter {
79
+ MemWriter { buf: buf }
80
}
81
82
/// Acquires an immutable reference to the underlying buffer of this
0 commit comments