Use a Box<[u8]> in BufReader

Saves a word, and also prevents the impl from accidentally changing the
buffer length.
This commit is contained in:
Steven Fackler 2016-01-20 22:40:25 -08:00
parent 51108b64ca
commit b740c557e2

View File

@ -47,7 +47,7 @@
#[stable(feature = "rust1", since = "1.0.0")]
pub struct BufReader<R> {
inner: R,
buf: Vec<u8>,
buf: Box<[u8]>,
pos: usize,
cap: usize,
}
@ -92,7 +92,7 @@ pub fn new(inner: R) -> BufReader<R> {
pub fn with_capacity(cap: usize, inner: R) -> BufReader<R> {
BufReader {
inner: inner,
buf: vec![0; cap],
buf: vec![0; cap].into_boxed_slice(),
pos: 0,
cap: 0,
}