mirror of https://git.sr.ht/~stygianentity/bincode
Fixed new clippy warnings (#617)
* Fixed new clippy warnings * Undid breaking all the tests * Fixed more clippy warnings --------- Co-authored-by: Victor Koenders <git@trang.ar>
This commit is contained in:
parent
b1bbcd0ea4
commit
3aa269bfea
|
|
@ -9,7 +9,7 @@ fn slice_varint_u8(c: &mut Criterion) {
|
|||
.take(10_000)
|
||||
.collect();
|
||||
let config = config::standard();
|
||||
let bytes = bincode::encode_to_vec(&input, config).unwrap();
|
||||
let bytes = bincode::encode_to_vec(input, config).unwrap();
|
||||
|
||||
c.bench_function("slice_varint_u8", |b| {
|
||||
b.iter(|| {
|
||||
|
|
@ -25,7 +25,7 @@ fn slice_varint_u16(c: &mut Criterion) {
|
|||
.take(10_000)
|
||||
.collect();
|
||||
let config = config::standard();
|
||||
let bytes = bincode::encode_to_vec(&input, config).unwrap();
|
||||
let bytes = bincode::encode_to_vec(input, config).unwrap();
|
||||
|
||||
c.bench_function("slice_varint_u16", |b| {
|
||||
b.iter(|| {
|
||||
|
|
@ -41,7 +41,7 @@ fn slice_varint_u32(c: &mut Criterion) {
|
|||
.take(10_000)
|
||||
.collect();
|
||||
let config = config::standard();
|
||||
let bytes = bincode::encode_to_vec(&input, config).unwrap();
|
||||
let bytes = bincode::encode_to_vec(input, config).unwrap();
|
||||
|
||||
c.bench_function("slice_varint_u32", |b| {
|
||||
b.iter(|| {
|
||||
|
|
@ -57,7 +57,7 @@ fn slice_varint_u64(c: &mut Criterion) {
|
|||
.take(10_000)
|
||||
.collect();
|
||||
let config = config::standard();
|
||||
let bytes = bincode::encode_to_vec(&input, config).unwrap();
|
||||
let bytes = bincode::encode_to_vec(input, config).unwrap();
|
||||
|
||||
c.bench_function("slice_varint_u64", |b| {
|
||||
b.iter(|| {
|
||||
|
|
@ -73,7 +73,7 @@ fn bufreader_varint_u8(c: &mut Criterion) {
|
|||
.take(10_000)
|
||||
.collect();
|
||||
let config = config::standard();
|
||||
let bytes = bincode::encode_to_vec(&input, config).unwrap();
|
||||
let bytes = bincode::encode_to_vec(input, config).unwrap();
|
||||
|
||||
c.bench_function("bufreader_varint_u8", |b| {
|
||||
b.iter(|| {
|
||||
|
|
@ -91,7 +91,7 @@ fn bufreader_varint_u16(c: &mut Criterion) {
|
|||
.take(10_000)
|
||||
.collect();
|
||||
let config = config::standard();
|
||||
let bytes = bincode::encode_to_vec(&input, config).unwrap();
|
||||
let bytes = bincode::encode_to_vec(input, config).unwrap();
|
||||
|
||||
c.bench_function("bufreader_varint_u16", |b| {
|
||||
b.iter(|| {
|
||||
|
|
@ -109,7 +109,7 @@ fn bufreader_varint_u32(c: &mut Criterion) {
|
|||
.take(10_000)
|
||||
.collect();
|
||||
let config = config::standard();
|
||||
let bytes = bincode::encode_to_vec(&input, config).unwrap();
|
||||
let bytes = bincode::encode_to_vec(input, config).unwrap();
|
||||
|
||||
c.bench_function("bufreader_varint_u32", |b| {
|
||||
b.iter(|| {
|
||||
|
|
@ -127,7 +127,7 @@ fn bufreader_varint_u64(c: &mut Criterion) {
|
|||
.take(10_000)
|
||||
.collect();
|
||||
let config = config::standard();
|
||||
let bytes = bincode::encode_to_vec(&input, config).unwrap();
|
||||
let bytes = bincode::encode_to_vec(input, config).unwrap();
|
||||
|
||||
c.bench_function("bufreader_varint_u64", |b| {
|
||||
b.iter(|| {
|
||||
|
|
|
|||
|
|
@ -606,7 +606,7 @@ where
|
|||
Ok(Err(u))
|
||||
}
|
||||
x => Err(DecodeError::UnexpectedVariant {
|
||||
found: x as u32,
|
||||
found: x,
|
||||
allowed: &crate::error::AllowedEnumVariants::Range { max: 1, min: 0 },
|
||||
type_name: core::any::type_name::<Result<T, U>>(),
|
||||
}),
|
||||
|
|
@ -631,7 +631,7 @@ where
|
|||
Ok(Err(u))
|
||||
}
|
||||
x => Err(DecodeError::UnexpectedVariant {
|
||||
found: x as u32,
|
||||
found: x,
|
||||
allowed: &crate::error::AllowedEnumVariants::Range { max: 1, min: 0 },
|
||||
type_name: core::any::type_name::<Result<T, U>>(),
|
||||
}),
|
||||
|
|
|
|||
|
|
@ -54,8 +54,8 @@ where
|
|||
let mut bytes = [0u8; 4];
|
||||
read.read(&mut bytes)?;
|
||||
Ok(match endian {
|
||||
Endian::Big => u32::from_be_bytes(bytes) as u32,
|
||||
Endian::Little => u32::from_le_bytes(bytes) as u32,
|
||||
Endian::Big => u32::from_be_bytes(bytes),
|
||||
Endian::Little => u32::from_le_bytes(bytes),
|
||||
})
|
||||
}
|
||||
U64_BYTE => invalid_varint_discriminant(IntegerType::U32, IntegerType::U64),
|
||||
|
|
@ -94,8 +94,8 @@ where
|
|||
let mut bytes = [0u8; 8];
|
||||
read.read(&mut bytes)?;
|
||||
Ok(match endian {
|
||||
Endian::Big => u64::from_be_bytes(bytes) as u64,
|
||||
Endian::Little => u64::from_le_bytes(bytes) as u64,
|
||||
Endian::Big => u64::from_be_bytes(bytes),
|
||||
Endian::Little => u64::from_le_bytes(bytes),
|
||||
})
|
||||
}
|
||||
U128_BYTE => invalid_varint_discriminant(IntegerType::U64, IntegerType::U128),
|
||||
|
|
@ -242,7 +242,7 @@ pub fn varint_decode_u32<R: Reader>(read: &mut R, endian: Endian) -> Result<u32,
|
|||
Endian::Little => u32::from_le_bytes(bytes[..4].try_into().unwrap()),
|
||||
};
|
||||
|
||||
(val as u32, 5)
|
||||
(val, 5)
|
||||
}
|
||||
U64_BYTE => return invalid_varint_discriminant(IntegerType::U32, IntegerType::U64),
|
||||
U128_BYTE => return invalid_varint_discriminant(IntegerType::U32, IntegerType::U128),
|
||||
|
|
@ -283,7 +283,7 @@ pub fn varint_decode_u64<R: Reader>(read: &mut R, endian: Endian) -> Result<u64,
|
|||
Endian::Little => u64::from_le_bytes(bytes[..8].try_into().unwrap()),
|
||||
};
|
||||
|
||||
(val as u64, 9)
|
||||
(val, 9)
|
||||
}
|
||||
U128_BYTE => return invalid_varint_discriminant(IntegerType::U32, IntegerType::U128),
|
||||
_ => return invalid_varint_discriminant(IntegerType::U32, IntegerType::Reserved),
|
||||
|
|
@ -371,7 +371,7 @@ pub fn varint_decode_u128<R: Reader>(read: &mut R, endian: Endian) -> Result<u12
|
|||
Endian::Little => u128::from_le_bytes(bytes[..16].try_into().unwrap()),
|
||||
};
|
||||
|
||||
(val as u128, 17)
|
||||
(val, 17)
|
||||
}
|
||||
_ => return invalid_varint_discriminant(IntegerType::Usize, IntegerType::Reserved),
|
||||
};
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
#![allow(clippy::blacklisted_name)]
|
||||
#![allow(clippy::disallowed_names)]
|
||||
#![cfg(feature = "alloc")]
|
||||
|
||||
extern crate alloc;
|
||||
|
|
|
|||
|
|
@ -245,7 +245,7 @@ fn test_duration_out_of_range() {
|
|||
let mut input = [0u8; 14];
|
||||
|
||||
bincode::encode_into_slice(
|
||||
&(u64::MAX, u32::MAX),
|
||||
(u64::MAX, u32::MAX),
|
||||
&mut input,
|
||||
bincode::config::standard(),
|
||||
)
|
||||
|
|
@ -269,7 +269,7 @@ fn test_duration_wrapping() {
|
|||
let mut input = [0u8; 14];
|
||||
|
||||
bincode::encode_into_slice(
|
||||
&(u64::MAX - 4, u32::MAX),
|
||||
(u64::MAX - 4, u32::MAX),
|
||||
&mut input,
|
||||
bincode::config::standard(),
|
||||
)
|
||||
|
|
|
|||
|
|
@ -63,7 +63,7 @@ impl MemCache {
|
|||
let config = bincode::config::standard();
|
||||
let mut guard = self.cache.write().unwrap();
|
||||
|
||||
let encoded = bincode::serde::encode_to_vec(&cache_data, config)?;
|
||||
let encoded = bincode::serde::encode_to_vec(cache_data, config)?;
|
||||
let cache_item = CacheItem::new(encoded, expire_seconds);
|
||||
|
||||
guard.insert(*key, cache_item);
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
#![allow(clippy::blacklisted_name)]
|
||||
#![allow(clippy::disallowed_names)]
|
||||
#![cfg(feature = "std")]
|
||||
|
||||
mod utils;
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ where
|
|||
CMP: Fn(&V, &V) -> bool,
|
||||
{
|
||||
let mut buffer = [0u8; 2048];
|
||||
let len = bincode::encode_into_slice(&element, &mut buffer, config).unwrap();
|
||||
let len = bincode::encode_into_slice(element, &mut buffer, config).unwrap();
|
||||
println!(
|
||||
"{:?} ({}): {:?} ({:?})",
|
||||
element,
|
||||
|
|
@ -40,7 +40,7 @@ where
|
|||
use bincode::error::EncodeError;
|
||||
|
||||
let mut buffer = [0u8; 2048];
|
||||
let len = bincode::serde::encode_into_slice(&element, &mut buffer, config);
|
||||
let len = bincode::serde::encode_into_slice(element, &mut buffer, config);
|
||||
|
||||
let decoded = bincode::serde::decode_from_slice(&buffer, config);
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue