From 73135d4451883d471b587996b790b705709af236 Mon Sep 17 00:00:00 2001 From: Kim Altintop Date: Wed, 9 Aug 2023 10:11:29 +0200 Subject: [PATCH] Implement `Display` for `NameOrAddress` Mainly for debugging, but hesitant to override the `Debug` impl for `Address` with the hex representation. --- crates/client-api/src/util.rs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/crates/client-api/src/util.rs b/crates/client-api/src/util.rs index 1aa0bc7fbd..26ddb7588d 100644 --- a/crates/client-api/src/util.rs +++ b/crates/client-api/src/util.rs @@ -1,6 +1,7 @@ mod flat_csv; pub mod websocket; +use core::fmt; use std::net::IpAddr; use axum::body::{Bytes, HttpBody}; @@ -106,3 +107,12 @@ impl<'de> serde::Deserialize<'de> for NameOrAddress { }) } } + +impl fmt::Display for NameOrAddress { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + match self { + Self::Address(addr) => f.write_str(&addr.to_hex()), + Self::Name(name) => f.write_str(name), + } + } +}