@@ -282,11 +282,11 @@ impl IpAddr {
282
282
/// let localhost_v4 = IpAddr::V4(Ipv4Addr::new(127, 0, 0, 1));
283
283
/// let localhost_v6 = IpAddr::V6(Ipv6Addr::new(0, 0, 0, 0, 0, 0, 0, 1));
284
284
///
285
- /// assert_eq!(IpAddr::parse_ascii (b"127.0.0.1"), Ok(localhost_v4));
286
- /// assert_eq!(IpAddr::parse_ascii (b"::1"), Ok(localhost_v6));
285
+ /// assert_eq!(IpAddr::from_bytes (b"127.0.0.1"), Ok(localhost_v4));
286
+ /// assert_eq!(IpAddr::from_bytes (b"::1"), Ok(localhost_v6));
287
287
/// ```
288
288
#[ unstable( feature = "addr_parse_ascii" , issue = "101035" ) ]
289
- pub fn parse_ascii ( b : & [ u8 ] ) -> Result < Self , AddrParseError > {
289
+ pub fn from_bytes ( b : & [ u8 ] ) -> Result < Self , AddrParseError > {
290
290
Parser :: new ( b) . parse_with ( |p| p. read_ip_addr ( ) , AddrKind :: Ip )
291
291
}
292
292
}
@@ -295,7 +295,7 @@ impl IpAddr {
295
295
impl FromStr for IpAddr {
296
296
type Err = AddrParseError ;
297
297
fn from_str ( s : & str ) -> Result < IpAddr , AddrParseError > {
298
- Self :: parse_ascii ( s. as_bytes ( ) )
298
+ Self :: from_bytes ( s. as_bytes ( ) )
299
299
}
300
300
}
301
301
@@ -309,10 +309,10 @@ impl Ipv4Addr {
309
309
///
310
310
/// let localhost = Ipv4Addr::new(127, 0, 0, 1);
311
311
///
312
- /// assert_eq!(Ipv4Addr::parse_ascii (b"127.0.0.1"), Ok(localhost));
312
+ /// assert_eq!(Ipv4Addr::from_bytes (b"127.0.0.1"), Ok(localhost));
313
313
/// ```
314
314
#[ unstable( feature = "addr_parse_ascii" , issue = "101035" ) ]
315
- pub fn parse_ascii ( b : & [ u8 ] ) -> Result < Self , AddrParseError > {
315
+ pub fn from_bytes ( b : & [ u8 ] ) -> Result < Self , AddrParseError > {
316
316
// don't try to parse if too long
317
317
if b. len ( ) > 15 {
318
318
Err ( AddrParseError ( AddrKind :: Ipv4 ) )
@@ -326,7 +326,7 @@ impl Ipv4Addr {
326
326
impl FromStr for Ipv4Addr {
327
327
type Err = AddrParseError ;
328
328
fn from_str ( s : & str ) -> Result < Ipv4Addr , AddrParseError > {
329
- Self :: parse_ascii ( s. as_bytes ( ) )
329
+ Self :: from_bytes ( s. as_bytes ( ) )
330
330
}
331
331
}
332
332
@@ -340,10 +340,10 @@ impl Ipv6Addr {
340
340
///
341
341
/// let localhost = Ipv6Addr::new(0, 0, 0, 0, 0, 0, 0, 1);
342
342
///
343
- /// assert_eq!(Ipv6Addr::parse_ascii (b"::1"), Ok(localhost));
343
+ /// assert_eq!(Ipv6Addr::from_bytes (b"::1"), Ok(localhost));
344
344
/// ```
345
345
#[ unstable( feature = "addr_parse_ascii" , issue = "101035" ) ]
346
- pub fn parse_ascii ( b : & [ u8 ] ) -> Result < Self , AddrParseError > {
346
+ pub fn from_bytes ( b : & [ u8 ] ) -> Result < Self , AddrParseError > {
347
347
Parser :: new ( b) . parse_with ( |p| p. read_ipv6_addr ( ) , AddrKind :: Ipv6 )
348
348
}
349
349
}
@@ -352,7 +352,7 @@ impl Ipv6Addr {
352
352
impl FromStr for Ipv6Addr {
353
353
type Err = AddrParseError ;
354
354
fn from_str ( s : & str ) -> Result < Ipv6Addr , AddrParseError > {
355
- Self :: parse_ascii ( s. as_bytes ( ) )
355
+ Self :: from_bytes ( s. as_bytes ( ) )
356
356
}
357
357
}
358
358
@@ -366,10 +366,10 @@ impl SocketAddrV4 {
366
366
///
367
367
/// let socket = SocketAddrV4::new(Ipv4Addr::new(127, 0, 0, 1), 8080);
368
368
///
369
- /// assert_eq!(SocketAddrV4::parse_ascii (b"127.0.0.1:8080"), Ok(socket));
369
+ /// assert_eq!(SocketAddrV4::from_bytes (b"127.0.0.1:8080"), Ok(socket));
370
370
/// ```
371
371
#[ unstable( feature = "addr_parse_ascii" , issue = "101035" ) ]
372
- pub fn parse_ascii ( b : & [ u8 ] ) -> Result < Self , AddrParseError > {
372
+ pub fn from_bytes ( b : & [ u8 ] ) -> Result < Self , AddrParseError > {
373
373
Parser :: new ( b) . parse_with ( |p| p. read_socket_addr_v4 ( ) , AddrKind :: SocketV4 )
374
374
}
375
375
}
@@ -378,7 +378,7 @@ impl SocketAddrV4 {
378
378
impl FromStr for SocketAddrV4 {
379
379
type Err = AddrParseError ;
380
380
fn from_str ( s : & str ) -> Result < SocketAddrV4 , AddrParseError > {
381
- Self :: parse_ascii ( s. as_bytes ( ) )
381
+ Self :: from_bytes ( s. as_bytes ( ) )
382
382
}
383
383
}
384
384
@@ -392,10 +392,10 @@ impl SocketAddrV6 {
392
392
///
393
393
/// let socket = SocketAddrV6::new(Ipv6Addr::new(0x2001, 0xdb8, 0, 0, 0, 0, 0, 1), 8080, 0, 0);
394
394
///
395
- /// assert_eq!(SocketAddrV6::parse_ascii (b"[2001:db8::1]:8080"), Ok(socket));
395
+ /// assert_eq!(SocketAddrV6::from_bytes (b"[2001:db8::1]:8080"), Ok(socket));
396
396
/// ```
397
397
#[ unstable( feature = "addr_parse_ascii" , issue = "101035" ) ]
398
- pub fn parse_ascii ( b : & [ u8 ] ) -> Result < Self , AddrParseError > {
398
+ pub fn from_bytes ( b : & [ u8 ] ) -> Result < Self , AddrParseError > {
399
399
Parser :: new ( b) . parse_with ( |p| p. read_socket_addr_v6 ( ) , AddrKind :: SocketV6 )
400
400
}
401
401
}
@@ -404,7 +404,7 @@ impl SocketAddrV6 {
404
404
impl FromStr for SocketAddrV6 {
405
405
type Err = AddrParseError ;
406
406
fn from_str ( s : & str ) -> Result < SocketAddrV6 , AddrParseError > {
407
- Self :: parse_ascii ( s. as_bytes ( ) )
407
+ Self :: from_bytes ( s. as_bytes ( ) )
408
408
}
409
409
}
410
410
@@ -419,11 +419,11 @@ impl SocketAddr {
419
419
/// let socket_v4 = SocketAddr::new(IpAddr::V4(Ipv4Addr::new(127, 0, 0, 1)), 8080);
420
420
/// let socket_v6 = SocketAddr::new(IpAddr::V6(Ipv6Addr::new(0, 0, 0, 0, 0, 0, 0, 1)), 8080);
421
421
///
422
- /// assert_eq!(SocketAddr::parse_ascii (b"127.0.0.1:8080"), Ok(socket_v4));
423
- /// assert_eq!(SocketAddr::parse_ascii (b"[::1]:8080"), Ok(socket_v6));
422
+ /// assert_eq!(SocketAddr::from_bytes (b"127.0.0.1:8080"), Ok(socket_v4));
423
+ /// assert_eq!(SocketAddr::from_bytes (b"[::1]:8080"), Ok(socket_v6));
424
424
/// ```
425
425
#[ unstable( feature = "addr_parse_ascii" , issue = "101035" ) ]
426
- pub fn parse_ascii ( b : & [ u8 ] ) -> Result < Self , AddrParseError > {
426
+ pub fn from_bytes ( b : & [ u8 ] ) -> Result < Self , AddrParseError > {
427
427
Parser :: new ( b) . parse_with ( |p| p. read_socket_addr ( ) , AddrKind :: Socket )
428
428
}
429
429
}
@@ -432,7 +432,7 @@ impl SocketAddr {
432
432
impl FromStr for SocketAddr {
433
433
type Err = AddrParseError ;
434
434
fn from_str ( s : & str ) -> Result < SocketAddr , AddrParseError > {
435
- Self :: parse_ascii ( s. as_bytes ( ) )
435
+ Self :: from_bytes ( s. as_bytes ( ) )
436
436
}
437
437
}
438
438
0 commit comments