From a57afd9e1ad8aa03b26035fbb4340ff974b80dce Mon Sep 17 00:00:00 2001 From: Paolo Barbolini Date: Wed, 29 Dec 2021 16:07:07 +0100 Subject: [PATCH] Remove useless allocation when serializing --- src/ipv4.rs | 2 +- src/ipv6.rs | 2 +- src/lib.rs | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/ipv4.rs b/src/ipv4.rs index 9cb84a4..9fde814 100644 --- a/src/ipv4.rs +++ b/src/ipv4.rs @@ -27,7 +27,7 @@ impl serde::Serialize for Ipv4Network { where S: serde::Serializer, { - serializer.serialize_str(&self.to_string()) + serializer.collect_str(self) } } diff --git a/src/ipv6.rs b/src/ipv6.rs index 608fd73..3928ff5 100644 --- a/src/ipv6.rs +++ b/src/ipv6.rs @@ -28,7 +28,7 @@ impl serde::Serialize for Ipv6Network { where S: serde::Serializer, { - serializer.serialize_str(&self.to_string()) + serializer.collect_str(self) } } diff --git a/src/lib.rs b/src/lib.rs index 84b3a26..4561ad8 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -46,7 +46,7 @@ impl serde::Serialize for IpNetwork { where S: serde::Serializer, { - serializer.serialize_str(&self.to_string()) + serializer.collect_str(self) } }