fn valid_ip(ip: String) -> Result<(), String> {
    let blocks = ip[..].split('.')
        .collect::<Vec<&str>>()
        .iter()
        .filter(|num| num.parse::<u8>().is_ok())
        .count();

    if blocks == 4 {
        Ok(())
    } else {
        Err("Please provide a valid IPv4. e.g. 127.0.0.1".to_string())
    }
}
/// Validate the correctness of the user provided ip
Validate the correctness of the user provided ip
Validate the correctness of the user provided ip
fn valid_ip(ip: String) -> Result<(), String> {
    let blocks = ip[..].split('.')
        .collect::<Vec<&str>>()
        .iter()
        .filter(|num| num.parse::<u8>().is_ok())
        .count();
    if blocks == 4 {
        Ok(())
    } else {
        Err("Please provide a valid IPv4. e.g. 127.0.0.1".to_string())
    }
}
fn valid_ip ( ip : String ) -> Result < ( ) , String > { let blocks = ip [ .. ] . split ( '.' ) . collect :: < Vec < & str > > ( ) . iter ( ) . filter ( | num | num . parse :: < u8 > ( ) . is_ok ( ) ) . count ( ) ; if blocks == 4 { Ok ( ( ) ) } else { Err ( " " . to_string ( ) ) } }
Validate the correctness of the user provided ip
Validate the correctness of the user provided ip
ip
String
ip
String