From 0d1b06b207da42ff23d3aaf03c0d4306df099096 Mon Sep 17 00:00:00 2001 From: Denis Drakhnia Date: Sun, 25 Aug 2024 15:29:18 +0300 Subject: [PATCH] refactor --- master/src/master_server.rs | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/master/src/master_server.rs b/master/src/master_server.rs index 034470b..d6d8ad4 100644 --- a/master/src/master_server.rs +++ b/master/src/master_server.rs @@ -9,6 +9,7 @@ use std::{ io, net::{Ipv4Addr, Ipv6Addr, SocketAddr, SocketAddrV4, SocketAddrV6, ToSocketAddrs, UdpSocket}, ops::Deref, + str::FromStr, sync::atomic::{AtomicBool, Ordering}, time::{Duration, Instant}, }; @@ -35,7 +36,7 @@ use crate::{ }; pub trait AddrExt: Sized + Eq + Hash + Display + Copy + ToSocketAddrs + ServerAddress { - type Ip; + type Ip: Eq + Hash + Display + Copy + FromStr; fn extract(addr: SocketAddr) -> Result; fn ip(&self) -> &Self::Ip; @@ -261,11 +262,7 @@ impl Master { } } -impl MasterServer -where - Addr: AddrExt, - Addr::Ip: Eq + Hash + Display + Copy + std::str::FromStr, -{ +impl MasterServer { pub fn new(cfg: Config, addr: Addr) -> Result { info!("Listen address: {}", addr); @@ -694,7 +691,6 @@ where fn helper(args: &[&str], mut op: F) where Addr: AddrExt, - Addr::Ip: std::str::FromStr, F: FnMut(&str, Addr::Ip), { let iter = args.iter().map(|i| (i, i.parse::()));