Skip to content

Commit

Permalink
Fixed new clippy lints (#721)
Browse files Browse the repository at this point in the history
* Fixed new clippy lints

* Fixed doc formatting warning

---------

Co-authored-by: Victor Koenders <victor.koenders@qrtech.se>
  • Loading branch information
VictorKoenders and VictorKoenders committed Aug 7, 2024
1 parent d3011fe commit df03a59
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 7 deletions.
3 changes: 1 addition & 2 deletions src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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`.
/// 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`.
/// 5. If `2**64 <= u < 2**128`, encode it as a literal byte 254, followed by a
/// u128 with value `u`.
/// 5. If `2**64 <= u < 2**128`, encode it as a literal byte 254, followed by a u128 with value `u`.
///
/// 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
Expand Down
4 changes: 2 additions & 2 deletions src/features/impl_alloc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ where
let mut vec = alloc::vec![0u8; len];
decoder.reader().read(&mut vec)?;
// Safety: Vec<T> is Vec<u8>
Ok(unsafe { core::mem::transmute(vec) })
Ok(unsafe { core::mem::transmute::<Vec<u8>, Vec<T>>(vec) })
} else {
decoder.claim_container_read::<T>(len)?;

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

Expand Down
2 changes: 1 addition & 1 deletion src/varint/decode_unsigned.rs
Original file line number Diff line number Diff line change
@@ -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 crate::{
Expand Down
4 changes: 2 additions & 2 deletions tests/alloc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -138,9 +138,9 @@ fn test_container_limits() {
let test_cases = &[
// u64::max_value(), should overflow
#[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")]
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
bincode::encode_to_vec(DECODE_LIMIT as u64, bincode::config::standard()).unwrap(),
];
Expand Down

0 comments on commit df03a59

Please # to comment.