@@ -646,10 +646,15 @@ impl Ipv6Addr {
646
646
/// # Examples
647
647
///
648
648
/// ```
649
+ /// #![feature(ip)]
650
+ ///
649
651
/// use std::net::Ipv6Addr;
650
652
///
651
- /// assert_eq!(Ipv6Addr::new(0, 0, 0, 0, 0, 0xffff, 0xc00a, 0x2ff).is_unique_local(), false);
652
- /// assert_eq!(Ipv6Addr::new(0xfc02, 0, 0, 0, 0, 0, 0, 0).is_unique_local(), true);
653
+ /// fn main() {
654
+ /// assert_eq!(Ipv6Addr::new(0, 0, 0, 0, 0, 0xffff, 0xc00a, 0x2ff).is_unique_local(),
655
+ /// false);
656
+ /// assert_eq!(Ipv6Addr::new(0xfc02, 0, 0, 0, 0, 0, 0, 0).is_unique_local(), true);
657
+ /// }
653
658
/// ```
654
659
pub fn is_unique_local ( & self ) -> bool {
655
660
( self . segments ( ) [ 0 ] & 0xfe00 ) == 0xfc00
@@ -664,11 +669,15 @@ impl Ipv6Addr {
664
669
/// # Examples
665
670
///
666
671
/// ```
672
+ /// #![feature(ip)]
673
+ ///
667
674
/// use std::net::Ipv6Addr;
668
675
///
669
- /// assert_eq!(Ipv6Addr::new(0, 0, 0, 0, 0, 0xffff, 0xc00a, 0x2ff).is_unicast_link_local(),
670
- /// false);
671
- /// assert_eq!(Ipv6Addr::new(0xfe8a, 0, 0, 0, 0, 0, 0, 0).is_unicast_link_local(), true);
676
+ /// fn main() {
677
+ /// assert_eq!(Ipv6Addr::new(0, 0, 0, 0, 0, 0xffff, 0xc00a, 0x2ff).is_unicast_link_local(),
678
+ /// false);
679
+ /// assert_eq!(Ipv6Addr::new(0xfe8a, 0, 0, 0, 0, 0, 0, 0).is_unicast_link_local(), true);
680
+ /// }
672
681
/// ```
673
682
pub fn is_unicast_link_local ( & self ) -> bool {
674
683
( self . segments ( ) [ 0 ] & 0xffc0 ) == 0xfe80
@@ -680,11 +689,15 @@ impl Ipv6Addr {
680
689
/// # Examples
681
690
///
682
691
/// ```
692
+ /// #![feature(ip)]
693
+ ///
683
694
/// use std::net::Ipv6Addr;
684
695
///
685
- /// assert_eq!(Ipv6Addr::new(0, 0, 0, 0, 0, 0xffff, 0xc00a, 0x2ff).is_unicast_site_local(),
686
- /// false);
687
- /// assert_eq!(Ipv6Addr::new(0xfec2, 0, 0, 0, 0, 0, 0, 0).is_unicast_site_local(), true);
696
+ /// fn main() {
697
+ /// assert_eq!(Ipv6Addr::new(0, 0, 0, 0, 0, 0xffff, 0xc00a, 0x2ff).is_unicast_site_local(),
698
+ /// false);
699
+ /// assert_eq!(Ipv6Addr::new(0xfec2, 0, 0, 0, 0, 0, 0, 0).is_unicast_site_local(), true);
700
+ /// }
688
701
/// ```
689
702
pub fn is_unicast_site_local ( & self ) -> bool {
690
703
( self . segments ( ) [ 0 ] & 0xffc0 ) == 0xfec0
@@ -700,10 +713,15 @@ impl Ipv6Addr {
700
713
/// # Examples
701
714
///
702
715
/// ```
716
+ /// #![feature(ip)]
717
+ ///
703
718
/// use std::net::Ipv6Addr;
704
719
///
705
- /// assert_eq!(Ipv6Addr::new(0, 0, 0, 0, 0, 0xffff, 0xc00a, 0x2ff).is_documentation(), false);
706
- /// assert_eq!(Ipv6Addr::new(0x2001, 0xdb8, 0, 0, 0, 0, 0, 0).is_documentation(), true);
720
+ /// fn main() {
721
+ /// assert_eq!(Ipv6Addr::new(0, 0, 0, 0, 0, 0xffff, 0xc00a, 0x2ff).is_documentation(),
722
+ /// false);
723
+ /// assert_eq!(Ipv6Addr::new(0x2001, 0xdb8, 0, 0, 0, 0, 0, 0).is_documentation(), true);
724
+ /// }
707
725
/// ```
708
726
pub fn is_documentation ( & self ) -> bool {
709
727
( self . segments ( ) [ 0 ] == 0x2001 ) && ( self . segments ( ) [ 1 ] == 0xdb8 )
@@ -723,10 +741,15 @@ impl Ipv6Addr {
723
741
/// # Examples
724
742
///
725
743
/// ```
744
+ /// #![feature(ip)]
745
+ ///
726
746
/// use std::net::Ipv6Addr;
727
747
///
728
- /// assert_eq!(Ipv6Addr::new(0x2001, 0xdb8, 0, 0, 0, 0, 0, 0).is_unicast_global(), false);
729
- /// assert_eq!(Ipv6Addr::new(0, 0, 0, 0, 0, 0xffff, 0xc00a, 0x2ff).is_unicast_global(), true);
748
+ /// fn main() {
749
+ /// assert_eq!(Ipv6Addr::new(0x2001, 0xdb8, 0, 0, 0, 0, 0, 0).is_unicast_global(), false);
750
+ /// assert_eq!(Ipv6Addr::new(0, 0, 0, 0, 0, 0xffff, 0xc00a, 0x2ff).is_unicast_global(),
751
+ /// true);
752
+ /// }
730
753
/// ```
731
754
pub fn is_unicast_global ( & self ) -> bool {
732
755
!self . is_multicast ( )
@@ -740,11 +763,15 @@ impl Ipv6Addr {
740
763
/// # Examples
741
764
///
742
765
/// ```
766
+ /// #![feature(ip)]
767
+ ///
743
768
/// use std::net::{Ipv6Addr, Ipv6MulticastScope};
744
769
///
745
- /// assert_eq!(Ipv6Addr::new(0xff0e, 0, 0, 0, 0, 0, 0, 0).multicast_scope(),
746
- /// Some(Ipv6MulticastScope::Global));
747
- /// assert_eq!(Ipv6Addr::new(0, 0, 0, 0, 0, 0xffff, 0xc00a, 0x2ff).multicast_scope(), None);
770
+ /// fn main() {
771
+ /// assert_eq!(Ipv6Addr::new(0xff0e, 0, 0, 0, 0, 0, 0, 0).multicast_scope(),
772
+ /// Some(Ipv6MulticastScope::Global));
773
+ /// assert_eq!(Ipv6Addr::new(0, 0, 0, 0, 0, 0xffff, 0xc00a, 0x2ff).multicast_scope(), None);
774
+ /// }
748
775
/// ```
749
776
pub fn multicast_scope ( & self ) -> Option < Ipv6MulticastScope > {
750
777
if self . is_multicast ( ) {
@@ -792,6 +819,8 @@ impl Ipv6Addr {
792
819
/// assert_eq!(Ipv6Addr::new(0xff00, 0, 0, 0, 0, 0, 0, 0).to_ipv4(), None);
793
820
/// assert_eq!(Ipv6Addr::new(0, 0, 0, 0, 0, 0xffff, 0xc00a, 0x2ff).to_ipv4(),
794
821
/// Some(Ipv4Addr::new(192, 10, 2, 255)));
822
+ /// assert_eq!(Ipv6Addr::new(0, 0, 0, 0, 0, 0, 0, 1).to_ipv4(),
823
+ /// Some(Ipv4Addr::new(0, 0, 0, 1)));
795
824
/// ```
796
825
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
797
826
pub fn to_ipv4 ( & self ) -> Option < Ipv4Addr > {
0 commit comments