1// Copyright 2018 Developers of the Rand project.
2//
3// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
4// https://www.apache.org/licenses/LICENSE-2.0> or the MIT license
5// <LICENSE-MIT or https://opensource.org/licenses/MIT>, at your
6// option. This file may not be copied, modified, or distributed
7// except according to those terms.
89//! Weighted index sampling
10//!
11//! This module is deprecated. Use [`crate::distributions::WeightedIndex`] and
12//! [`crate::distributions::WeightedError`] instead.
1314pub use super::{WeightedIndex, WeightedError};
1516#[allow(missing_docs)]
17#[deprecated(since = "0.8.0", note = "moved to rand_distr crate")]
18pub mod alias_method {
19// This module exists to provide a deprecation warning which minimises
20 // compile errors, but still fails to compile if ever used.
21use core::marker::PhantomData;
22use alloc::vec::Vec;
23use super::WeightedError;
2425#[derive(Debug)]
26pub struct WeightedIndex<W: Weight> {
27 _phantom: PhantomData<W>,
28 }
29impl<W: Weight> WeightedIndex<W> {
30pub fn new(_weights: Vec<W>) -> Result<Self, WeightedError> {
31Err(WeightedError::NoItem)
32 }
33 }
3435pub trait Weight {}
36macro_rules! impl_weight {
37 () => {};
38 ($T:ident, $($more:ident,)*) => {
39impl Weight for $T {}
40impl_weight!($($more,)*);
41 };
42 }
43impl_weight!(f64, f32,);
44impl_weight!(u8, u16, u32, u64, usize,);
45impl_weight!(i8, i16, i32, i64, isize,);
46#[cfg(not(target_os = "emscripten"))]
47impl_weight!(u128, i128,);
48}