Fixed getting IP address from CLI
This commit is contained in:
parent
f2ad0de89b
commit
4f8412f3d0
@ -9,15 +9,15 @@ fn main() {
|
||||
loop {
|
||||
let mut ip = String::new();
|
||||
io::stdin().read_line(&mut ip).unwrap();
|
||||
let ip_address = match IpAddr::from_str(x) {
|
||||
|
||||
let ip_address = match IpAddr::from_str(&ip.trim()) {
|
||||
Err(_) => {
|
||||
println!("fucked it");
|
||||
IpAddr::V4(0, 0, 0, 0)
|
||||
println!("{} is an invalid IP Address... Please try again", ip);
|
||||
continue;
|
||||
},
|
||||
Ok(ip) => ip,
|
||||
};
|
||||
|
||||
println!("you entered, {:?}", ip_address);
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user