Skip to content

Commit 18e7167

Browse files
committed
Remove old deprecated functionality
1 parent 2b0cbed commit 18e7167

File tree

7 files changed

+1
-370
lines changed

7 files changed

+1
-370
lines changed

benches/misc.rs

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -149,17 +149,6 @@ fn gen_1k_iter_repeat(b: &mut Bencher) {
149149
b.bytes = 1024;
150150
}
151151

152-
#[bench]
153-
#[allow(deprecated)]
154-
fn gen_1k_gen_iter(b: &mut Bencher) {
155-
let mut rng = SmallRng::from_rng(&mut thread_rng()).unwrap();
156-
b.iter(|| {
157-
let v: Vec<u64> = rng.gen_iter().take(128).collect();
158-
v
159-
});
160-
b.bytes = 1024;
161-
}
162-
163152
#[bench]
164153
fn gen_1k_sample_iter(b: &mut Bencher) {
165154
use rand::distributions::{Distribution, Standard};

src/distributions/mod.rs

Lines changed: 0 additions & 118 deletions
Original file line numberDiff line numberDiff line change
@@ -167,8 +167,6 @@ use Rng;
167167
#[doc(inline)] pub use self::other::Alphanumeric;
168168
#[doc(inline)] pub use self::uniform::Uniform;
169169
#[doc(inline)] pub use self::float::{OpenClosed01, Open01};
170-
#[deprecated(since="0.5.0", note="use Uniform instead")]
171-
pub use self::uniform::Uniform as Range;
172170
#[cfg(feature="std")]
173171
#[doc(inline)] pub use self::gamma::{Gamma, ChiSquared, FisherF, StudentT};
174172
#[cfg(feature="std")]
@@ -204,89 +202,6 @@ mod ziggurat_tables;
204202
#[cfg(feature="std")]
205203
use distributions::float::IntoFloat;
206204

207-
/// Types that can be used to create a random instance of `Support`.
208-
#[deprecated(since="0.5.0", note="use Distribution instead")]
209-
pub trait Sample<Support> {
210-
/// Generate a random value of `Support`, using `rng` as the
211-
/// source of randomness.
212-
fn sample<R: Rng>(&mut self, rng: &mut R) -> Support;
213-
}
214-
215-
/// `Sample`s that do not require keeping track of state.
216-
///
217-
/// Since no state is recorded, each sample is (statistically)
218-
/// independent of all others, assuming the `Rng` used has this
219-
/// property.
220-
#[allow(deprecated)]
221-
#[deprecated(since="0.5.0", note="use Distribution instead")]
222-
pub trait IndependentSample<Support>: Sample<Support> {
223-
/// Generate a random value.
224-
fn ind_sample<R: Rng>(&self, &mut R) -> Support;
225-
}
226-
227-
/// DEPRECATED: Use `distributions::uniform` instead.
228-
#[deprecated(since="0.5.0", note="use uniform instead")]
229-
pub mod range {
230-
pub use distributions::uniform::Uniform as Range;
231-
pub use distributions::uniform::SampleUniform as SampleRange;
232-
}
233-
234-
#[allow(deprecated)]
235-
mod impls {
236-
use Rng;
237-
use distributions::{Distribution, Sample, IndependentSample,
238-
WeightedChoice};
239-
#[cfg(feature="std")]
240-
use distributions::exponential::Exp;
241-
#[cfg(feature="std")]
242-
use distributions::gamma::{Gamma, ChiSquared, FisherF, StudentT};
243-
#[cfg(feature="std")]
244-
use distributions::normal::{Normal, LogNormal};
245-
use distributions::range::{Range, SampleRange};
246-
247-
impl<'a, T: Clone> Sample<T> for WeightedChoice<'a, T> {
248-
fn sample<R: Rng>(&mut self, rng: &mut R) -> T {
249-
Distribution::sample(self, rng)
250-
}
251-
}
252-
impl<'a, T: Clone> IndependentSample<T> for WeightedChoice<'a, T> {
253-
fn ind_sample<R: Rng>(&self, rng: &mut R) -> T {
254-
Distribution::sample(self, rng)
255-
}
256-
}
257-
258-
impl<T: SampleRange> Sample<T> for Range<T> {
259-
fn sample<R: Rng>(&mut self, rng: &mut R) -> T {
260-
Distribution::sample(self, rng)
261-
}
262-
}
263-
impl<T: SampleRange> IndependentSample<T> for Range<T> {
264-
fn ind_sample<R: Rng>(&self, rng: &mut R) -> T {
265-
Distribution::sample(self, rng)
266-
}
267-
}
268-
269-
#[cfg(feature="std")]
270-
macro_rules! impl_f64 {
271-
($($name: ident), *) => {
272-
$(
273-
impl Sample<f64> for $name {
274-
fn sample<R: Rng>(&mut self, rng: &mut R) -> f64 {
275-
Distribution::sample(self, rng)
276-
}
277-
}
278-
impl IndependentSample<f64> for $name {
279-
fn ind_sample<R: Rng>(&self, rng: &mut R) -> f64 {
280-
Distribution::sample(self, rng)
281-
}
282-
}
283-
)*
284-
}
285-
}
286-
#[cfg(feature="std")]
287-
impl_f64!(Exp, Gamma, ChiSquared, FisherF, StudentT, Normal, LogNormal);
288-
}
289-
290205
/// Types (distributions) that can be used to create a random instance of `T`.
291206
///
292207
/// It is possible to sample from a distribution through both the
@@ -434,13 +349,6 @@ impl<'a, D, R, T> Iterator for DistIter<'a, D, R, T>
434349
#[derive(Clone, Copy, Debug)]
435350
pub struct Standard;
436351

437-
#[allow(deprecated)]
438-
impl<T> ::Rand for T where Standard: Distribution<T> {
439-
fn rand<R: Rng>(rng: &mut R) -> Self {
440-
Standard.sample(rng)
441-
}
442-
}
443-
444352

445353
/// A value with a particular weight for use with `WeightedChoice`.
446354
#[derive(Copy, Clone, Debug)]
@@ -626,7 +534,6 @@ fn ziggurat<R: Rng + ?Sized, P, Z>(
626534

627535
#[cfg(test)]
628536
mod tests {
629-
use Rng;
630537
use rngs::mock::StepRng;
631538
use super::{WeightedChoice, Weighted, Distribution};
632539

@@ -732,31 +639,6 @@ mod tests {
732639
Weighted { weight: 1, item: 3 }]);
733640
}
734641

735-
#[test] #[allow(deprecated)]
736-
fn test_backwards_compat_sample() {
737-
use distributions::{Sample, IndependentSample};
738-
739-
struct Constant<T> { val: T }
740-
impl<T: Copy> Sample<T> for Constant<T> {
741-
fn sample<R: Rng>(&mut self, _: &mut R) -> T { self.val }
742-
}
743-
impl<T: Copy> IndependentSample<T> for Constant<T> {
744-
fn ind_sample<R: Rng>(&self, _: &mut R) -> T { self.val }
745-
}
746-
747-
let mut sampler = Constant{ val: 293 };
748-
assert_eq!(sampler.sample(&mut ::test::rng(233)), 293);
749-
assert_eq!(sampler.ind_sample(&mut ::test::rng(234)), 293);
750-
}
751-
752-
#[cfg(feature="std")]
753-
#[test] #[allow(deprecated)]
754-
fn test_backwards_compat_exp() {
755-
use distributions::{IndependentSample, Exp};
756-
let sampler = Exp::new(1.0);
757-
sampler.ind_sample(&mut ::test::rng(235));
758-
}
759-
760642
#[cfg(feature="std")]
761643
#[test]
762644
fn test_distributions_iter() {

0 commit comments

Comments
 (0)