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