File tree Expand file tree Collapse file tree 1 file changed +22
-1
lines changed Expand file tree Collapse file tree 1 file changed +22
-1
lines changed Original file line number Diff line number Diff line change 66// option. This file may not be copied, modified, or distributed 
77// except according to those terms. 
88
9- use  crate :: net:: { Ipv4Addr ,  Ipv6Addr } ; 
9+ use  crate :: net:: { IpAddr ,   Ipv4Addr ,  Ipv6Addr } ; 
1010use  alloc:: borrow:: Cow ; 
1111use  alloc:: borrow:: ToOwned ; 
1212use  alloc:: string:: String ; 
@@ -200,6 +200,27 @@ where
200200    } 
201201} 
202202
203+ impl < S >  From < Ipv4Addr >  for  Host < S >  { 
204+     fn  from ( ipv4 :  Ipv4Addr )  -> Self  { 
205+         Self :: Ipv4 ( ipv4) 
206+     } 
207+ } 
208+ 
209+ impl < S >  From < Ipv6Addr >  for  Host < S >  { 
210+     fn  from ( ipv6 :  Ipv6Addr )  -> Self  { 
211+         Self :: Ipv6 ( ipv6) 
212+     } 
213+ } 
214+ 
215+ impl < S >  From < IpAddr >  for  Host < S >  { 
216+     fn  from ( ip :  IpAddr )  -> Self  { 
217+         match  ip { 
218+             IpAddr :: V4 ( ipv4)  => ipv4. into ( ) , 
219+             IpAddr :: V6 ( ipv6)  => ipv6. into ( ) , 
220+         } 
221+     } 
222+ } 
223+ 
203224fn  write_ipv6 ( addr :  & Ipv6Addr ,  f :  & mut  Formatter < ' _ > )  -> fmt:: Result  { 
204225    let  segments = addr. segments ( ) ; 
205226    let  ( compress_start,  compress_end)  = longest_zero_sequence ( & segments) ; 
 
 
   
 
     
   
   
          
    
    
     
    
      
     
     
    You can’t perform that action at this time.
  
 
    
  
    
      
        
     
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments