Skip to content

Commit

Permalink
Merge pull request #39 from paolobarbolini/collect-str
Browse files Browse the repository at this point in the history
Use `Serializer::collect_str` to serialize output of Display
  • Loading branch information
krisprice authored Mar 27, 2023
2 parents 80b8bd9 + d52314e commit 1096c55
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/ipnet_serde.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down Expand Up @@ -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() {
Expand Down

0 comments on commit 1096c55

Please sign in to comment.