Skip to content

Commit 59df78f

Browse files
authored
Merge branch 'master' into impl-error-for-distr-error
2 parents 68816c7 + 5643fd5 commit 59df78f

File tree

2 files changed

+9
-17
lines changed

2 files changed

+9
-17
lines changed

rand_distr/benches/distributions.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88

99
#![feature(test)]
1010

11+
extern crate test;
12+
1113
const RAND_BENCH_N: u64 = 1000;
1214

1315
use std::mem::size_of;

src/distributions/weighted/mod.rs

Lines changed: 7 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -364,26 +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-
}
368+
impl ::std::error::Error for WeightedError {}
384369

385370
impl fmt::Display for WeightedError {
386371
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
387-
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+
}
388378
}
389379
}

0 commit comments

Comments
 (0)