-
Notifications
You must be signed in to change notification settings - Fork 13.2k
/
Copy pathipv6.rs
53 lines (36 loc) · 1.7 KB
/
ipv6.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
// run-pass
#![feature(ip)]
#![feature(const_ipv6)]
use std::net::{Ipv4Addr, Ipv6Addr, Ipv6MulticastScope};
fn main() {
const IP_ADDRESS : Ipv6Addr = Ipv6Addr::new(0, 0, 0, 0, 0, 0, 0, 1);
assert_eq!(IP_ADDRESS, Ipv6Addr::LOCALHOST);
const SEGMENTS : [u16; 8] = IP_ADDRESS.segments();
assert_eq!(SEGMENTS, [0 ,0 ,0 ,0 ,0 ,0 ,0, 1]);
const OCTETS : [u8; 16] = IP_ADDRESS.octets();
assert_eq!(OCTETS, [0 ,0 ,0 ,0 ,0 ,0 ,0, 0 ,0 ,0 ,0 ,0 ,0 ,0, 0, 1]);
const IS_UNSPECIFIED : bool = IP_ADDRESS.is_unspecified();
assert!(!IS_UNSPECIFIED);
const IS_LOOPBACK : bool = IP_ADDRESS.is_loopback();
assert!(IS_LOOPBACK);
const IS_GLOBAL : bool = IP_ADDRESS.is_global();
assert!(!IS_GLOBAL);
const IS_UNIQUE_LOCAL : bool = IP_ADDRESS.is_unique_local();
assert!(!IS_UNIQUE_LOCAL);
const IS_UNICAST_LINK_LOCAL_STRICT : bool = IP_ADDRESS.is_unicast_link_local_strict();
assert!(!IS_UNICAST_LINK_LOCAL_STRICT);
const IS_UNICAST_LINK_LOCAL : bool = IP_ADDRESS.is_unicast_link_local();
assert!(!IS_UNICAST_LINK_LOCAL);
const IS_UNICAST_SITE_LOCAL : bool = IP_ADDRESS.is_unicast_site_local();
assert!(!IS_UNICAST_SITE_LOCAL);
const IS_DOCUMENTATION : bool = IP_ADDRESS.is_documentation();
assert!(!IS_DOCUMENTATION);
const IS_UNICAST_GLOBAL : bool = IP_ADDRESS.is_unicast_global();
assert!(!IS_UNICAST_GLOBAL);
const MULTICAST_SCOPE : Option<Ipv6MulticastScope> = IP_ADDRESS.multicast_scope();
assert_eq!(MULTICAST_SCOPE, None);
const IS_MULTICAST : bool = IP_ADDRESS.is_multicast();
assert!(!IS_MULTICAST);
const IP_V4 : Option<Ipv4Addr> = IP_ADDRESS.to_ipv4();
assert_eq!(IP_V4.unwrap(), Ipv4Addr::new(0, 0, 0, 1));
}