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 6
6
// option. This file may not be copied, modified, or distributed
7
7
// except according to those terms.
8
8
9
- use crate :: net:: { Ipv4Addr , Ipv6Addr } ;
9
+ use crate :: net:: { IpAddr , Ipv4Addr , Ipv6Addr } ;
10
10
use alloc:: borrow:: Cow ;
11
11
use alloc:: borrow:: ToOwned ;
12
12
use alloc:: string:: String ;
@@ -200,6 +200,27 @@ where
200
200
}
201
201
}
202
202
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
+
203
224
fn write_ipv6 ( addr : & Ipv6Addr , f : & mut Formatter < ' _ > ) -> fmt:: Result {
204
225
let segments = addr. segments ( ) ;
205
226
let ( compress_start, compress_end) = longest_zero_sequence ( & segments) ;
You can’t perform that action at this time.
0 commit comments