Skip to content

Commit 61fc476

Browse files
committed
Clippy
1 parent 09eade5 commit 61fc476

File tree

43 files changed

+441
-486
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+441
-486
lines changed

rmp-serde/Cargo.toml

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "rmp-serde"
3-
version = "1.3.0"
3+
version = "1.3.1"
44
authors = ["Evgeny Safronov <division494@gmail.com>"]
55
license = "MIT"
66
description = "Serde bindings for RMP"
@@ -9,20 +9,21 @@ documentation = "https://docs.rs/rmp-serde"
99
readme = "README.md"
1010
keywords = ["msgpack", "MessagePack", "serde", "serialization"]
1111
categories = ["encoding"]
12-
edition = "2021"
12+
edition = "2024"
13+
rust-version = "1.85"
1314

1415
[package.metadata.release]
1516
tag-prefix = "{{crate_name}}/"
1617

1718
[dependencies]
18-
byteorder = "1.4.3"
19-
serde = "1.0.197"
19+
byteorder = "1.5.0"
20+
serde = "1.0.228"
2021
rmp = { version = "0.8.14", path = "../rmp" }
2122

2223
[dev-dependencies]
2324
rmpv = { path = "../rmpv" }
24-
serde_bytes = "0.11.5"
25-
serde = { version = "1.0.197", features = ["derive"] }
25+
serde_bytes = "0.11.19"
26+
serde = { version = "1.0.228", features = ["derive"] }
2627

2728
[badges]
2829
maintenance = { status = "looking-for-maintainer" }

rmp-serde/benches/buf.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,7 @@ fn bench_strings_10000(bencher: &mut Bencher) {
2222
}
2323

2424
fn bench_strings(bencher: &mut Bencher, size: usize) {
25-
let vec: Vec<String> = ::std::iter::repeat("abcdefghijklmnopqrstuvwxyz".into())
26-
.take(size)
27-
.collect();
25+
let vec: Vec<String> = std::iter::repeat_n("abcdefghijklmnopqrstuvwxyz".into(), size).collect();
2826

2927
let mut buf = Vec::new();
3028
vec.serialize(&mut rmp_serde::Serializer::new(&mut buf)).unwrap();

rmp-serde/src/bytes.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -35,15 +35,15 @@ impl serde::de::Error for Nope {
3535
}
3636

3737
impl serde::Serializer for OnlyBytes {
38-
type Ok = u8;
3938
type Error = Nope;
39+
type Ok = u8;
40+
type SerializeMap = Impossible<u8, Nope>;
4041
type SerializeSeq = Impossible<u8, Nope>;
42+
type SerializeStruct = Impossible<u8, Nope>;
43+
type SerializeStructVariant = Impossible<u8, Nope>;
4144
type SerializeTuple = Impossible<u8, Nope>;
4245
type SerializeTupleStruct = Impossible<u8, Nope>;
4346
type SerializeTupleVariant = Impossible<u8, Nope>;
44-
type SerializeMap = Impossible<u8, Nope>;
45-
type SerializeStruct = Impossible<u8, Nope>;
46-
type SerializeStructVariant = Impossible<u8, Nope>;
4747

4848
fn serialize_u8(self, val: u8) -> Result<u8, Nope> {
4949
Ok(val)
@@ -105,7 +105,7 @@ impl serde::Serializer for OnlyBytes {
105105
Err(Nope)
106106
}
107107

108-
fn serialize_some<T: ?Sized>(self, _: &T) -> Result<u8, Nope> where T: Serialize {
108+
fn serialize_some<T>(self, _: &T) -> Result<u8, Nope> where T: Serialize + ?Sized {
109109
Err(Nope)
110110
}
111111

@@ -121,11 +121,11 @@ impl serde::Serializer for OnlyBytes {
121121
Err(Nope)
122122
}
123123

124-
fn serialize_newtype_struct<T: ?Sized>(self, _: &'static str, _: &T) -> Result<u8, Nope> where T: Serialize {
124+
fn serialize_newtype_struct<T>(self, _: &'static str, _: &T) -> Result<u8, Nope> where T: Serialize + ?Sized {
125125
Err(Nope)
126126
}
127127

128-
fn serialize_newtype_variant<T: ?Sized>(self, _: &'static str, _: u32, _: &'static str, _: &T) -> Result<u8, Nope> where T: Serialize {
128+
fn serialize_newtype_variant<T>(self, _: &'static str, _: u32, _: &'static str, _: &T) -> Result<u8, Nope> where T: Serialize + ?Sized {
129129
Err(Nope)
130130
}
131131

@@ -165,7 +165,7 @@ impl serde::Serializer for OnlyBytes {
165165
Err(Nope)
166166
}
167167

168-
fn collect_str<T: ?Sized>(self, _: &T) -> Result<u8, Nope> where T: fmt::Display {
168+
fn collect_str<T>(self, _: &T) -> Result<u8, Nope> where T: fmt::Display + ?Sized {
169169
Err(Nope)
170170
}
171171
}

rmp-serde/src/config.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ impl sealed::SerializerConfig for RuntimeConfig {
8989
/// - Writes structs as a tuple, without field names
9090
/// - Writes enum variants as integers
9191
/// - Writes and reads types as binary, not human-readable
92-
//
92+
///
9393
/// This is the most compact representation.
9494
#[derive(Copy, Clone, Debug)]
9595
pub struct DefaultConfig;

rmp-serde/src/decode.rs

Lines changed: 21 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -96,12 +96,11 @@ impl Display for Error {
9696
Self::InvalidDataRead(ref err) => write!(fmt, "IO error while reading data: {err}"),
9797
Self::TypeMismatch(ref actual_marker) => {
9898
write!(fmt, "wrong msgpack marker {actual_marker:?}")
99-
}
99+
},
100100
Self::OutOfRange => fmt.write_str("numeric cast found out of range"),
101-
Self::LengthMismatch(expected_length) => write!(
102-
fmt,
103-
"array had incorrect length, expected {expected_length}"
104-
),
101+
Self::LengthMismatch(expected_length) => {
102+
write!(fmt, "array had incorrect length, expected {expected_length}")
103+
},
105104
Self::Uncategorized(ref msg) => write!(fmt, "uncategorized error: {msg}"),
106105
Self::Syntax(ref msg) => fmt.write_str(msg),
107106
Self::Utf8Error(ref err) => write!(fmt, "string found to be invalid utf8: {err}"),
@@ -360,9 +359,9 @@ fn read_str_data<'de, V, R>(rd: &mut R, len: u32, visitor: V) -> Result<V::Value
360359
Ok(buf) => Ok(buf),
361360
Err(..) => Err(Error::Utf8Error(err)),
362361
}
363-
}
362+
},
364363
}
365-
}
364+
},
366365
Reference::Copied(buf) => {
367366
match str::from_utf8(buf) {
368367
Ok(s) => visitor.visit_str(s),
@@ -372,9 +371,9 @@ fn read_str_data<'de, V, R>(rd: &mut R, len: u32, visitor: V) -> Result<V::Value
372371
Ok(buf) => Ok(buf),
373372
Err(..) => Err(Error::Utf8Error(err)),
374373
}
375-
}
374+
},
376375
}
377-
}
376+
},
378377
}
379378
}
380379

@@ -480,15 +479,15 @@ impl<'de, 'a, R: ReadSlice<'de> + 'a, C: SerializerConfig> de::Deserializer<'de>
480479
let tag = self.rd.read_data_i8()?;
481480
self.state = ExtDeserializerState::ReadTag;
482481
visitor.visit_i8(tag)
483-
}
482+
},
484483
ExtDeserializerState::ReadTag => {
485484
let data = self.rd.read_slice(self.len as usize).map_err(Error::InvalidDataRead)?;
486485
self.state = ExtDeserializerState::ReadBinary;
487486
match data {
488487
Reference::Borrowed(bytes) => visitor.visit_borrowed_bytes(bytes),
489488
Reference::Copied(bytes) => visitor.visit_bytes(bytes),
490489
}
491-
}
490+
},
492491
ExtDeserializerState::ReadBinary => {
493492
debug_assert!(false);
494493
Err(Error::TypeMismatch(Marker::Reserved))
@@ -553,10 +552,8 @@ impl<'de, R: ReadSlice<'de>, C: SerializerConfig> Deserializer<R, C> {
553552
_ => return Err(Error::TypeMismatch(Marker::Reserved)),
554553
}?;
555554
read_str_data(&mut self.rd, len, visitor)
556-
}
557-
Marker::FixArray(_) |
558-
Marker::Array16 |
559-
Marker::Array32 => {
555+
},
556+
Marker::FixArray(_) | Marker::Array16 | Marker::Array32 => {
560557
let len = match marker {
561558
Marker::FixArray(len) => len.into(),
562559
Marker::Array16 => read_u16(&mut self.rd)?.into(),
@@ -572,10 +569,8 @@ impl<'de, R: ReadSlice<'de>, C: SerializerConfig> Deserializer<R, C> {
572569
excess => Err(Error::LengthMismatch(len - excess)),
573570
}
574571
})
575-
}
576-
Marker::FixMap(_) |
577-
Marker::Map16 |
578-
Marker::Map32 => {
572+
},
573+
Marker::FixMap(_) | Marker::Map16 | Marker::Map32 => {
579574
let len = match marker {
580575
Marker::FixMap(len) => len.into(),
581576
Marker::Map16 => read_u16(&mut self.rd)?.into(),
@@ -591,7 +586,7 @@ impl<'de, R: ReadSlice<'de>, C: SerializerConfig> Deserializer<R, C> {
591586
excess => Err(Error::LengthMismatch(len - excess)),
592587
}
593588
})
594-
}
589+
},
595590
Marker::Bin8 | Marker::Bin16 | Marker::Bin32 => {
596591
let len = match marker {
597592
Marker::Bin8 => read_u8(&mut self.rd).map(u32::from),
@@ -606,7 +601,7 @@ impl<'de, R: ReadSlice<'de>, C: SerializerConfig> Deserializer<R, C> {
606601
visitor.visit_seq(SeqDeserializer::new(buf.iter().copied()))
607602
},
608603
}
609-
}
604+
},
610605
Marker::FixExt1 |
611606
Marker::FixExt2 |
612607
Marker::FixExt4 |
@@ -617,7 +612,7 @@ impl<'de, R: ReadSlice<'de>, C: SerializerConfig> Deserializer<R, C> {
617612
Marker::Ext32 => {
618613
let len = ext_len(&mut self.rd, marker)?;
619614
depth_count!(self.depth, visitor.visit_newtype_struct(ExtDeserializer::new(self, len)))
620-
}
615+
},
621616
Marker::Reserved => Err(Error::TypeMismatch(Marker::Reserved)),
622617
}
623618
}
@@ -677,7 +672,7 @@ impl<'de, R: ReadSlice<'de>, C: SerializerConfig> serde::Deserializer<'de> for &
677672
1 => {
678673
self.marker = None;
679674
visitor.visit_enum(VariantAccess::new(self))
680-
}
675+
},
681676
n => Err(Error::LengthMismatch(n)),
682677
},
683678
// TODO: Check this is a string
@@ -710,7 +705,7 @@ impl<'de, R: ReadSlice<'de>, C: SerializerConfig> serde::Deserializer<'de> for &
710705
marker => {
711706
self.marker = Some(marker);
712707
self.deserialize_any(visitor)
713-
}
708+
},
714709
}
715710
}
716711

@@ -1163,8 +1158,8 @@ where R: Read,
11631158
///
11641159
/// #[derive(Debug, Deserialize, PartialEq)]
11651160
/// struct Dog<'a> {
1166-
/// name: &'a str,
1167-
/// age: u8,
1161+
/// name: &'a str,
1162+
/// age: u8,
11681163
/// }
11691164
///
11701165
/// assert_eq!(Dog { name: "Bobby", age: 8 }, rmp_serde::from_slice(&buf).unwrap());

0 commit comments

Comments
 (0)