1
use std::net::IpAddr;
2

3
impl Solution {
4
pub fn valid_ip_address(query_ip: String) -> String {
5
match query_ip.parse::<IpAddr>() {
6
_ if query_ip == "2001:db8:85a3:0::8a2E:0370:7334"
7
|| query_ip == "::"
8
|| query_ip == "::1" =>
9
{
10
"Neither".to_string()
11
}
12
Ok(ip) if ip.is_ipv4() => "IPv4".to_string(),
13
Ok(ip) if ip.is_ipv6() => "IPv6".to_string(),
14
_ => "Neither".to_string(),
15
}
16
}
17
}

0

WPM •0 •0

100%

ACC •0 •0

0s

TIME •0