Fixed new clippy lints (#721)

* Fixed new clippy lints

* Fixed doc formatting warning

---------

Co-authored-by: Victor Koenders <victor.koenders@qrtech.se>
This commit is contained in:
Trangar 2024-08-07 10:21:30 +02:00 committed by GitHub
parent fe5a43334f
commit 7d402398cd
4 changed files with 6 additions and 7 deletions

View File

@ -96,8 +96,7 @@ impl<E, I, L> Configuration<E, I, L> {
/// 2. If `251 <= u < 2**16`, encode it as a literal byte 251, followed by a u16 with value `u`. /// 2. If `251 <= u < 2**16`, encode it as a literal byte 251, followed by a u16 with value `u`.
/// 3. If `2**16 <= u < 2**32`, encode it as a literal byte 252, followed by a u32 with value `u`. /// 3. If `2**16 <= u < 2**32`, encode it as a literal byte 252, followed by a u32 with value `u`.
/// 4. If `2**32 <= u < 2**64`, encode it as a literal byte 253, followed by a u64 with value `u`. /// 4. If `2**32 <= u < 2**64`, encode it as a literal byte 253, followed by a u64 with value `u`.
/// 5. If `2**64 <= u < 2**128`, encode it as a literal byte 254, followed by a /// 5. If `2**64 <= u < 2**128`, encode it as a literal byte 254, followed by a u128 with value `u`.
/// u128 with value `u`.
/// ///
/// Then, for signed integers, we first convert to unsigned using the zigzag algorithm, /// Then, for signed integers, we first convert to unsigned using the zigzag algorithm,
/// and then encode them as we do for unsigned integers generally. The reason we use this /// and then encode them as we do for unsigned integers generally. The reason we use this

View File

@ -261,7 +261,7 @@ where
let mut vec = alloc::vec![0u8; len]; let mut vec = alloc::vec![0u8; len];
decoder.reader().read(&mut vec)?; decoder.reader().read(&mut vec)?;
// Safety: Vec<T> is Vec<u8> // Safety: Vec<T> is Vec<u8>
Ok(unsafe { core::mem::transmute(vec) }) Ok(unsafe { core::mem::transmute::<Vec<u8>, Vec<T>>(vec) })
} else { } else {
decoder.claim_container_read::<T>(len)?; decoder.claim_container_read::<T>(len)?;
@ -290,7 +290,7 @@ where
let mut vec = alloc::vec![0u8; len]; let mut vec = alloc::vec![0u8; len];
decoder.reader().read(&mut vec)?; decoder.reader().read(&mut vec)?;
// Safety: Vec<T> is Vec<u8> // Safety: Vec<T> is Vec<u8>
Ok(unsafe { core::mem::transmute(vec) }) Ok(unsafe { core::mem::transmute::<Vec<u8>, Vec<T>>(vec) })
} else { } else {
decoder.claim_container_read::<T>(len)?; decoder.claim_container_read::<T>(len)?;

View File

@ -1,4 +1,4 @@
use core::{convert::TryInto, u32}; use core::convert::TryInto;
use super::{SINGLE_BYTE_MAX, U128_BYTE, U16_BYTE, U32_BYTE, U64_BYTE}; use super::{SINGLE_BYTE_MAX, U128_BYTE, U16_BYTE, U32_BYTE, U64_BYTE};
use crate::{ use crate::{

View File

@ -138,9 +138,9 @@ fn test_container_limits() {
let test_cases = &[ let test_cases = &[
// u64::max_value(), should overflow // u64::max_value(), should overflow
#[cfg(target_pointer_width = "64")] #[cfg(target_pointer_width = "64")]
bincode::encode_to_vec(u64::max_value(), bincode::config::standard()).unwrap(), bincode::encode_to_vec(u64::MAX, bincode::config::standard()).unwrap(),
#[cfg(target_pointer_width = "32")] #[cfg(target_pointer_width = "32")]
bincode::encode_to_vec(u32::max_value(), bincode::config::standard()).unwrap(), bincode::encode_to_vec(u32::MAX, bincode::config::standard()).unwrap(),
// A high value which doesn't overflow, but exceeds the decode limit // A high value which doesn't overflow, but exceeds the decode limit
bincode::encode_to_vec(DECODE_LIMIT as u64, bincode::config::standard()).unwrap(), bincode::encode_to_vec(DECODE_LIMIT as u64, bincode::config::standard()).unwrap(),
]; ];