Guest User

Untitled

a guest
Jun 18th, 2018
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.38 KB | None | 0 0
  1. #![allow(unused)]
  2. fn main() {
  3. use std::net::{IpAddr, Ipv4Addr, Ipv6Addr};
  4.  
  5. let localhost_v4 = IpAddr::V4(Ipv4Addr::new(127, 0, 0, 1));
  6. let localhost_v6 = IpAddr::V6(Ipv6Addr::new(0, 0, 0, 0, 0, 0, 0, 1));
  7.  
  8. assert_eq!("127.0.0.1".parse(), Ok(localhost_v4));
  9. assert_eq!("::1".parse(), Ok(localhost_v6));
  10.  
  11. assert_eq!(localhost_v4.is_ipv6(), false);
  12. assert_eq!(localhost_v4.is_ipv4(), true);
  13. }
Add Comment
Please, Sign In to add comment