Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #![allow(unused)]
- fn main() {
- use std::net::{IpAddr, Ipv4Addr, Ipv6Addr};
- let localhost_v4 = IpAddr::V4(Ipv4Addr::new(127, 0, 0, 1));
- let localhost_v6 = IpAddr::V6(Ipv6Addr::new(0, 0, 0, 0, 0, 0, 0, 1));
- assert_eq!("127.0.0.1".parse(), Ok(localhost_v4));
- assert_eq!("::1".parse(), Ok(localhost_v6));
- assert_eq!(localhost_v4.is_ipv6(), false);
- assert_eq!(localhost_v4.is_ipv4(), true);
- }
Add Comment
Please, Sign In to add comment