mirror of https://git.sr.ht/~stygianentity/bincode
Fixed clippy lint, removed function that was only used in 1 place
This commit is contained in:
parent
99de47a6c8
commit
382b2c7a8f
|
|
@ -413,7 +413,6 @@ where
|
|||
// Safety: we know that T is a u8, so it is perfectly safe to
|
||||
// translate an array of u8 into an array of T
|
||||
let res = unsafe { ptr.read() };
|
||||
core::mem::forget(buf);
|
||||
Ok(res)
|
||||
} else {
|
||||
let result =
|
||||
|
|
|
|||
|
|
@ -69,16 +69,6 @@ impl<'storage> SliceReader<'storage> {
|
|||
pub fn new(bytes: &'storage [u8]) -> SliceReader<'storage> {
|
||||
SliceReader { slice: bytes }
|
||||
}
|
||||
|
||||
#[inline(always)]
|
||||
fn get_byte_slice(&mut self, length: usize) -> Result<&'storage [u8], DecodeError> {
|
||||
if length > self.slice.len() {
|
||||
return Err(DecodeError::UnexpectedEnd);
|
||||
}
|
||||
let (read_slice, remaining) = self.slice.split_at(length);
|
||||
self.slice = remaining;
|
||||
Ok(read_slice)
|
||||
}
|
||||
}
|
||||
|
||||
impl<'storage> Reader for SliceReader<'storage> {
|
||||
|
|
@ -108,6 +98,11 @@ impl<'storage> Reader for SliceReader<'storage> {
|
|||
impl<'storage> BorrowReader<'storage> for SliceReader<'storage> {
|
||||
#[inline(always)]
|
||||
fn take_bytes(&mut self, length: usize) -> Result<&'storage [u8], DecodeError> {
|
||||
self.get_byte_slice(length)
|
||||
if length > self.slice.len() {
|
||||
return Err(DecodeError::UnexpectedEnd);
|
||||
}
|
||||
let (read_slice, remaining) = self.slice.split_at(length);
|
||||
self.slice = remaining;
|
||||
Ok(read_slice)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -52,7 +52,7 @@ impl<'storage> Writer for SliceWriter<'storage> {
|
|||
return Err(EncodeError::UnexpectedEnd);
|
||||
}
|
||||
let (a, b) = core::mem::replace(&mut self.slice, &mut []).split_at_mut(bytes.len());
|
||||
a.copy_from_slice(&bytes[..]);
|
||||
a.copy_from_slice(bytes);
|
||||
self.slice = b;
|
||||
|
||||
Ok(())
|
||||
|
|
|
|||
Loading…
Reference in New Issue