abonander / buf_redux

A drop-in replacement for Rust's std::io::BufReader, with extra features
Apache License 2.0
38 stars 16 forks source link

Add `Buffer::resize` and `Buffer::truncate`. #16

Open oblique opened 5 years ago

oblique commented 5 years ago

These methods enable users to use Buffer without having an intermediate array.

For example:

let mut buffer = Buffer::with_capacity(1024);
buffer.resize(1024, 0);
let len = fill_some_data(buffer.buf_mut());
buffer.truncate(len);