Skip to content

Commit 6d66da9

Browse files
authored
Merge pull request #499 from dhardy/0.6
Remove functionality deprecated in or before 0.5
2 parents 319a384 + c2b83d3 commit 6d66da9

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
@@ -170,8 +170,6 @@ use Rng;
170170
#[doc(inline)] pub use self::other::Alphanumeric;
171171
#[doc(inline)] pub use self::uniform::Uniform;
172172
#[doc(inline)] pub use self::float::{OpenClosed01, Open01};
173-
#[deprecated(since="0.5.0", note="use Uniform instead")]
174-
pub use self::uniform::Uniform as Range;
175173
#[cfg(feature="std")]
176174
#[doc(inline)] pub use self::gamma::{Gamma, ChiSquared, FisherF, StudentT};
177175
#[cfg(feature="std")]
@@ -215,89 +213,6 @@ mod ziggurat_tables;
215213
#[cfg(feature="std")]
216214
use distributions::float::IntoFloat;
217215

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

448-
#[allow(deprecated)]
449-
impl<T> ::Rand for T where Standard: Distribution<T> {
450-
fn rand<R: Rng>(rng: &mut R) -> Self {
451-
Standard.sample(rng)
452-
}
453-
}
454-
455363

456364
/// A value with a particular weight for use with `WeightedChoice`.
457365
#[derive(Copy, Clone, Debug)]
@@ -637,7 +545,6 @@ fn ziggurat<R: Rng + ?Sized, P, Z>(
637545

638546
#[cfg(test)]
639547
mod tests {
640-
use Rng;
641548
use rngs::mock::StepRng;
642549
use super::{WeightedChoice, Weighted, Distribution};
643550

@@ -743,31 +650,6 @@ mod tests {
743650
Weighted { weight: 1, item: 3 }]);
744651
}
745652

746-
#[test] #[allow(deprecated)]
747-
fn test_backwards_compat_sample() {
748-
use distributions::{Sample, IndependentSample};
749-
750-
struct Constant<T> { val: T }
751-
impl<T: Copy> Sample<T> for Constant<T> {
752-
fn sample<R: Rng>(&mut self, _: &mut R) -> T { self.val }
753-
}
754-
impl<T: Copy> IndependentSample<T> for Constant<T> {
755-
fn ind_sample<R: Rng>(&self, _: &mut R) -> T { self.val }
756-
}
757-
758-
let mut sampler = Constant{ val: 293 };
759-
assert_eq!(sampler.sample(&mut ::test::rng(233)), 293);
760-
assert_eq!(sampler.ind_sample(&mut ::test::rng(234)), 293);
761-
}
762-
763-
#[cfg(feature="std")]
764-
#[test] #[allow(deprecated)]
765-
fn test_backwards_compat_exp() {
766-
use distributions::{IndependentSample, Exp};
767-
let sampler = Exp::new(1.0);
768-
sampler.ind_sample(&mut ::test::rng(235));
769-
}
770-
771653
#[cfg(feature="std")]
772654
#[test]
773655
fn test_distributions_iter() {

0 commit comments

Comments
 (0)