Skip to content

Commit 5643fd5

Browse files
authored
Merge pull request #920 from AnderEnder/remove-deprecated-error-description
Remove deprecated Error::description and Error::cause
2 parents 1096cdb + d186bc5 commit 5643fd5

File tree

1 file changed

+7
-20
lines changed
  • src/distributions/weighted

1 file changed

+7
-20
lines changed

src/distributions/weighted/mod.rs

Lines changed: 7 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -364,29 +364,16 @@ pub enum WeightedError {
364364
TooMany,
365365
}
366366

367-
impl WeightedError {
368-
fn msg(&self) -> &str {
369-
match *self {
370-
WeightedError::NoItem => "No weights provided.",
371-
WeightedError::InvalidWeight => "A weight is invalid.",
372-
WeightedError::AllWeightsZero => "All weights are zero.",
373-
WeightedError::TooMany => "Too many weights (hit u32::MAX)",
374-
}
375-
}
376-
}
377-
378367
#[cfg(feature="std")]
379-
impl ::std::error::Error for WeightedError {
380-
fn description(&self) -> &str {
381-
self.msg()
382-
}
383-
fn cause(&self) -> Option<&dyn (::std::error::Error)> {
384-
None
385-
}
386-
}
368+
impl ::std::error::Error for WeightedError {}
387369

388370
impl fmt::Display for WeightedError {
389371
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
390-
write!(f, "{}", self.msg())
372+
match *self {
373+
WeightedError::NoItem => write!(f, "No weights provided."),
374+
WeightedError::InvalidWeight => write!(f, "A weight is invalid."),
375+
WeightedError::AllWeightsZero => write!(f, "All weights are zero."),
376+
WeightedError::TooMany => write!(f, "Too many weights (hit u32::MAX)"),
377+
}
391378
}
392379
}

0 commit comments

Comments
 (0)