diff options
| author | bors <bors@rust-lang.org> | 2015-08-24 16:00:42 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2015-08-24 16:00:42 +0000 |
| commit | b74ec4c847388a5d34688186347eb9ebb3d6115b (patch) | |
| tree | 7242ecd4eca09a2c172ced1d5c9ffd4ff4600266 /src/libstd | |
| parent | 797d0ba59c3d11a61bdfca52b79d511580309713 (diff) | |
| parent | f266f12f3066c02cfef6116202e624443f919dff (diff) | |
| download | rust-b74ec4c847388a5d34688186347eb9ebb3d6115b.tar.gz rust-b74ec4c847388a5d34688186347eb9ebb3d6115b.zip | |
Auto merge of #27976 - sfackler:addrparseerror-error, r=alexcrichton
Closes #27973
Diffstat (limited to 'src/libstd')
| -rw-r--r-- | src/libstd/net/parser.rs | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/src/libstd/net/parser.rs b/src/libstd/net/parser.rs index b0fadb56f36..480fd63c36a 100644 --- a/src/libstd/net/parser.rs +++ b/src/libstd/net/parser.rs @@ -15,8 +15,10 @@ use prelude::v1::*; -use str::FromStr; +use error::Error; +use fmt; use net::{IpAddr, Ipv4Addr, Ipv6Addr, SocketAddr, SocketAddrV4, SocketAddrV6}; +use str::FromStr; struct Parser<'a> { // parsing as ASCII, so can use byte array @@ -339,3 +341,17 @@ impl FromStr for SocketAddr { #[stable(feature = "rust1", since = "1.0.0")] #[derive(Debug, Clone, PartialEq)] pub struct AddrParseError(()); + +#[stable(feature = "addr_parse_error_error", since = "1.4.0")] +impl fmt::Display for AddrParseError { + fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { + fmt.write_str(self.description()) + } +} + +#[stable(feature = "addr_parse_error_error", since = "1.4.0")] +impl Error for AddrParseError { + fn description(&self) -> &str { + "invalid IP address syntax" + } +} |
