Tried but can't seem to get Console input (Includes newline character)
This commit is contained in:
		
							
								
								
									
										20
									
								
								src/main.rs
									
									
									
									
									
								
							
							
						
						
									
										20
									
								
								src/main.rs
									
									
									
									
									
								
							@@ -1,5 +1,23 @@
 | 
			
		||||
use std::{io, str::FromStr};
 | 
			
		||||
 | 
			
		||||
mod networking;
 | 
			
		||||
use networking::ip::{IpAddr};
 | 
			
		||||
 | 
			
		||||
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);
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -1,4 +1,4 @@
 | 
			
		||||
mod ip;
 | 
			
		||||
pub mod ip;
 | 
			
		||||
use ip::IpAddr;
 | 
			
		||||
 | 
			
		||||
#[allow(unused)]
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user