From d52314ed500ab934a38cc5109ca3c9e29a5b5b59 Mon Sep 17 00:00:00 2001 From: Paolo Barbolini Date: Mon, 7 Mar 2022 09:38:01 +0100 Subject: [PATCH] Use Serializer::collect_str to serialize output of Display --- src/ipnet_serde.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/ipnet_serde.rs b/src/ipnet_serde.rs index a79fb31..96ac595 100644 --- a/src/ipnet_serde.rs +++ b/src/ipnet_serde.rs @@ -81,7 +81,7 @@ impl Serialize for Ipv4Net { where S: Serializer { if serializer.is_human_readable() { - serializer.serialize_str(&self.to_string()) + serializer.collect_str(self) } else { let mut seq = serializer.serialize_tuple(5)?; for octet in &self.addr().octets() { @@ -127,7 +127,7 @@ impl Serialize for Ipv6Net { where S: Serializer { if serializer.is_human_readable() { - serializer.serialize_str(&self.to_string()) + serializer.collect_str(self) } else { let mut seq = serializer.serialize_tuple(17)?; for octet in &self.addr().octets() {