Drop the length hint for Serde serializations
These `Serialize` implementations are all explicitly focused around
JSON serialization, which does not require a length hint for map
serialization. By using `None`, we remove one more thing a programmer
has to remember to change when updating these implementations in the
future.
@@ -233,7 +233,9 @@ impl<'a> Serialize for Package<'a> {
where
S: Serializer,
{
- let mut map = serializer.serialize_map(Some(20))?;
+ // Explicitly focusing on JSON serialization, which does not
+ // need a length hint (thus the `None`)
+ let mut map = serializer.serialize_map(None)?;
// This is really the only thing that we need to have a custom
// `Serialize` implementation for. Alternatively, we could
@@ -336,7 +338,9 @@ impl<'a> Serialize for Svc<'a> {
where
S: Serializer,
{
- let mut map = serializer.serialize_map(Some(14))?;
+ // Explicitly focusing on JSON serialization, which does not
+ // need a length hint (thus the `None`)
+ let mut map = serializer.serialize_map(None)?;
map.serialize_entry(
"service",
@@ -504,7 +508,9 @@ impl<'a> Serialize for SvcMember<'a> {
where
S: Serializer,
{
- let mut map = serializer.serialize_map(Some(24))?;
+ // Explicitly focusing on JSON serialization, which does not
+ // need a length hint (thus the `None`)
+ let mut map = serializer.serialize_map(None)?;
map.serialize_entry("member_id", &self.member_id)?;
