diff --git a/hptp-recv/src/main.rs b/hptp-recv/src/main.rs index 122188c..8b1ce00 100644 --- a/hptp-recv/src/main.rs +++ b/hptp-recv/src/main.rs @@ -1,10 +1,13 @@ extern crate hptp; #[derive(Debug)] -struct Hostname(String, u16); +struct Hostname { + ip: String, + port: u16, +} fn go(hn: Hostname) { - println!("{:?}", hn) + println!("ip={}, port={}", hn.ip, hn.port) } fn usage() { @@ -15,9 +18,12 @@ fn parse_args() -> Result { let mut args = std::env::args(); let arg = args.nth(1).ok_or(())?; let i = arg.find(':').ok_or(())?; - let ip: String = arg[..i].into(); - let port: u16 = arg[i + 1..].parse::().map_err(|_| ())?; - Ok(Hostname(ip, port)) + let ip = &arg[..i]; + let port: u16 = arg[i + 1..].parse().map_err(|_| ())?; + Ok(Hostname { + ip: ip.into(), + port, + }) } fn main() {