From 135968d8f1379a6d2f32cbbc3e5b77a5f317a4d6 Mon Sep 17 00:00:00 2001 From: hozan23 Date: Mon, 24 Jun 2024 02:18:03 +0200 Subject: p2p/examples: remove redundant code --- net/src/endpoint.rs | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'net') diff --git a/net/src/endpoint.rs b/net/src/endpoint.rs index 9fb949b..c3626ec 100644 --- a/net/src/endpoint.rs +++ b/net/src/endpoint.rs @@ -35,6 +35,7 @@ pub type Port = u16; /// #[derive(Debug, Clone, PartialEq, Eq, Hash)] #[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] +#[cfg_attr(feature = "serde", serde(into = "String"))] pub enum Endpoint { Udp(Addr, Port), Tcp(Addr, Port), @@ -68,6 +69,11 @@ impl std::fmt::Display for Endpoint { } } } +impl From for String { + fn from(endpoint: Endpoint) -> String { + endpoint.to_string() + } +} impl TryFrom for SocketAddr { type Error = Error; -- cgit v1.2.3