Skip to content

Commit 1d7b009

Browse files
committed
Eliminate closures capturing needlessly many type parameters
1 parent 89c4b02 commit 1d7b009

File tree

1 file changed

+20
-7
lines changed

1 file changed

+20
-7
lines changed

serde/src/private/de.rs

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -476,14 +476,16 @@ mod content {
476476
where
477477
D: Deserializer<'de>,
478478
{
479-
Deserialize::deserialize(deserializer).map(|v| Content::Some(Box::new(v)))
479+
let v = tri!(Deserialize::deserialize(deserializer));
480+
Ok(Content::Some(Box::new(v)))
480481
}
481482

482483
fn visit_newtype_struct<D>(self, deserializer: D) -> Result<Self::Value, D::Error>
483484
where
484485
D: Deserializer<'de>,
485486
{
486-
Deserialize::deserialize(deserializer).map(|v| Content::Newtype(Box::new(v)))
487+
let v = tri!(Deserialize::deserialize(deserializer));
488+
Ok(Content::Newtype(Box::new(v)))
487489
}
488490

489491
fn visit_seq<V>(self, mut visitor: V) -> Result<Self::Value, V::Error>
@@ -1113,9 +1115,13 @@ mod content {
11131115
V: Visitor<'de>,
11141116
E: de::Error,
11151117
{
1116-
let map = content
1117-
.into_iter()
1118-
.map(|(k, v)| (ContentDeserializer::new(k), ContentDeserializer::new(v)));
1118+
fn content_deserializer_pair<'de, E>(
1119+
(k, v): (Content<'de>, Content<'de>),
1120+
) -> (ContentDeserializer<'de, E>, ContentDeserializer<'de, E>) {
1121+
(ContentDeserializer::new(k), ContentDeserializer::new(v))
1122+
}
1123+
1124+
let map = content.into_iter().map(content_deserializer_pair);
11191125
let mut map_visitor = MapDeserializer::new(map);
11201126
let value = tri!(visitor.visit_map(&mut map_visitor));
11211127
tri!(map_visitor.end());
@@ -1709,12 +1715,19 @@ mod content {
17091715
V: Visitor<'de>,
17101716
E: de::Error,
17111717
{
1712-
let map = content.iter().map(|(k, v)| {
1718+
fn content_ref_deserializer_pair<'a, 'de, E>(
1719+
(k, v): &'a (Content<'de>, Content<'de>),
1720+
) -> (
1721+
ContentRefDeserializer<'a, 'de, E>,
1722+
ContentRefDeserializer<'a, 'de, E>,
1723+
) {
17131724
(
17141725
ContentRefDeserializer::new(k),
17151726
ContentRefDeserializer::new(v),
17161727
)
1717-
});
1728+
}
1729+
1730+
let map = content.iter().map(content_ref_deserializer_pair);
17181731
let mut map_visitor = MapDeserializer::new(map);
17191732
let value = tri!(visitor.visit_map(&mut map_visitor));
17201733
tri!(map_visitor.end());

0 commit comments

Comments
 (0)