Skip to content

Commit

Permalink
Fix Error::description() deprecation warning
Browse files Browse the repository at this point in the history
Deprecated since Rust 1.42.0, but does not require 1.42.0, because deprecation
has been prepared in rust-lang/rust#50163
by providing a default implementation.
  • Loading branch information
niklasf committed May 26, 2021
1 parent 506f5c9 commit e9e6efc
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 12 deletions.
8 changes: 2 additions & 6 deletions src/ipnet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -113,15 +113,11 @@ pub struct PrefixLenError;

impl fmt::Display for PrefixLenError {
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
fmt.write_str(self.description())
fmt.write_str("invalid IP prefix length")
}
}

impl Error for PrefixLenError {
fn description(&self) -> &str {
"invalid IP prefix length"
}
}
impl Error for PrefixLenError {}

impl IpNet {
/// Returns a copy of the network with the address truncated to the
Expand Down
8 changes: 2 additions & 6 deletions src/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -338,12 +338,8 @@ pub struct AddrParseError(());

impl fmt::Display for AddrParseError {
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
fmt.write_str(self.description())
fmt.write_str("invalid IP address syntax")
}
}

impl Error for AddrParseError {
fn description(&self) -> &str {
"invalid IP address syntax"
}
}
impl Error for AddrParseError {}

0 comments on commit e9e6efc

Please sign in to comment.