/// Create a new buffer with a given capacity. Note that the capacity is 
/// only a soft limit. The buffer will always allow you to write more than 
/// its capacity.
Create a new buffer with a given capacity. Note that the capacity is
only a soft limit. The buffer will always allow you to write more than
its capacity.
Create a new buffer with a given capacity . Note that the capacity is only a soft limit . The buffer will always allow you to write more than its capacity .
pub fn new(capacity: usize) -> WriteBuffer {
        let mut res = WriteBuffer {
            buffer:   Vec::with_capacity(capacity),
            capacity: capacity,
            offset:   0,
            used:     0
        };
        // TODO: replace this with resize (after it's stabilized)
        let buf_capacity = res.buffer.capacity();
        unsafe {
            res.buffer.set_len(buf_capacity);
        }
        res
    }
pub fn new ( capacity : usize ) -> WriteBuffer { let mut res = WriteBuffer { buffer : Vec :: with_capacity ( capacity ) , capacity : capacity , offset : 0 , used : 0 } ; // TODO: replace this with resize (after it's stabilized) let buf_capacity = res . buffer . capacity ( ) ; unsafe { res . buffer . set_len ( buf_capacity ) ; } res }
Create a new buffer with a given capacity.
Create a new buffer with a given capacity .
capacity
usize