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