fix some slicing issues
This commit is contained in:
parent
1d8b1466ff
commit
2e336270c8
|
@ -306,11 +306,13 @@ mod file {
|
||||||
range: Range<usize>,
|
range: Range<usize>,
|
||||||
) -> BufferSlice<'a, u8> {
|
) -> BufferSlice<'a, u8> {
|
||||||
let index = range.start;
|
let index = range.start;
|
||||||
let mut vec = Vec::with_capacity(range.end - range.start);
|
let len = range.end - range.start;
|
||||||
|
let mut vec = Vec::with_capacity(len);
|
||||||
|
vec.set_len(len);
|
||||||
let mut refmut = self.borrow_mut();
|
let mut refmut = self.borrow_mut();
|
||||||
refmut
|
refmut
|
||||||
.seek(SeekFrom::Start(index as u64))
|
.seek(SeekFrom::Start(index as u64))
|
||||||
.and_then(|_| refmut.read_exact(&mut vec[range]))
|
.and_then(|_| refmut.read_exact(&mut vec[..]))
|
||||||
.unwrap_or_else(|err| {
|
.unwrap_or_else(|err| {
|
||||||
panic!("could't read from File Buffer: {:?}", err)
|
panic!("could't read from File Buffer: {:?}", err)
|
||||||
});
|
});
|
||||||
|
|
Reference in a new issue