Moved varialble out of loop to extend scope

This commit is contained in:
Luke Else 2023-03-06 21:42:31 +00:00
parent 41fc1a3f6d
commit a9bb5c1d52

View File

@ -6,14 +6,16 @@ mod networking;
fn main() {
println!("Enter the IP and cidr for your given network");
let ip_and_cidr: (networking::ip::IpAddr, u8);
loop {
let mut cidr: u8;
let mut ip: String = Default::default();
let mut cidr: u8 = Default::default();
let mut ip_buf = String::new();
io::stdin().read_line(&mut ip_buf).unwrap_or_default();
let ip_and_cidr = match networking::ip_and_cidr_from_string(&ip_buf) {
ip_and_cidr = match networking::ip_and_cidr_from_string(&ip_buf) {
Err(_) => {
println!("{} is an invalid IP Address... Please try again", ip_buf);
continue;
@ -23,4 +25,6 @@ fn main() {
break;
}
println!("IP: {}, CIDR: {}", ip_and_cidr.0.to_string(), ip_and_cidr.1);
}