Tried but can't seem to get Console input (Includes newline character)

This commit is contained in:
Luke Else 2023-02-11 17:41:33 +00:00
parent 43cd0f5bc5
commit f2ad0de89b
2 changed files with 20 additions and 2 deletions

View File

@ -1,5 +1,23 @@
use std::{io, str::FromStr};
mod networking; mod networking;
use networking::ip::{IpAddr};
fn main() { fn main() {
println!("Hello, World!") println!("Enter the IP and CIDR for your given network");
loop {
let mut ip = String::new();
io::stdin().read_line(&mut ip).unwrap();
let ip_address = match IpAddr::from_str(x) {
Err(_) => {
println!("fucked it");
IpAddr::V4(0, 0, 0, 0)
},
Ok(ip) => ip,
};
println!("you entered, {:?}", ip_address);
}
} }

View File

@ -1,4 +1,4 @@
mod ip; pub mod ip;
use ip::IpAddr; use ip::IpAddr;
#[allow(unused)] #[allow(unused)]