| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
pub use super::{WeightedIndex, WeightedError}; |
| 15 |
|
| 16 |
#[allow(missing_docs)] |
| 17 |
#[deprecated(since = "0.8.0", note = "moved to rand_distr crate")] |
| 18 |
pub mod alias_method { |
| 19 |
|
| 20 |
|
| 21 |
use core::marker::PhantomData; |
| 22 |
use alloc::vec::Vec; |
| 23 |
use super::WeightedError; |
| 24 |
|
| 25 |
#[derive(Debug)] |
| 26 |
pub struct WeightedIndex<W: Weight> { |
| 27 |
_phantom: PhantomData<W>, |
| 28 |
} |
| 29 |
impl<W: Weight> WeightedIndex<W> { |
| 30 |
pub fn new(_weights: Vec<W>) -> Result<Self, WeightedError> { |
| 31 |
Err(WeightedError::NoItem) |
| 32 |
} |
| 33 |
} |
| 34 |
|
| 35 |
pub trait Weight {} |
| 36 |
macro_rules! impl_weight { |
| 37 |
() => {}; |
| 38 |
($T:ident, $($more:ident,)*) => { |
| 39 |
impl Weight for $T {} |
| 40 |
impl_weight!($($more,)*); |
| 41 |
}; |
| 42 |
} |
| 43 |
impl_weight!(f64, f32,); |
| 44 |
impl_weight!(u8, u16, u32, u64, usize,); |
| 45 |
impl_weight!(i8, i16, i32, i64, isize,); |
| 46 |
impl_weight!(u128, i128,); |
| 47 |
} |