Skip to content

Commit 8d63428

Browse files
committed
rand: Delete all doc tests
None of these actually compile any more!
1 parent ebc9b48 commit 8d63428

File tree

8 files changed

+0
-456
lines changed

8 files changed

+0
-456
lines changed

src/librand/distributions/exponential.rs

-12
Original file line numberDiff line numberDiff line change
@@ -56,18 +56,6 @@ impl Rand for Exp1 {
5656
///
5757
/// This distribution has density function: `f(x) = lambda *
5858
/// exp(-lambda * x)` for `x > 0`.
59-
///
60-
/// # Examples
61-
///
62-
/// ```
63-
/// # #![feature(rand)]
64-
/// use std::rand;
65-
/// use std::rand::distributions::{Exp, IndependentSample};
66-
///
67-
/// let exp = Exp::new(2.0);
68-
/// let v = exp.ind_sample(&mut rand::thread_rng());
69-
/// println!("{} is from a Exp(2) distribution", v);
70-
/// ```
7159
#[derive(Copy, Clone)]
7260
pub struct Exp {
7361
/// `lambda` stored as `1/lambda`, since this is what we scale by.

src/librand/distributions/gamma.rs

-48
Original file line numberDiff line numberDiff line change
@@ -37,18 +37,6 @@ use super::{IndependentSample, Sample, Exp};
3737
/// == 1`, and using the boosting technique described in [1] for
3838
/// `shape < 1`.
3939
///
40-
/// # Examples
41-
///
42-
/// ```
43-
/// # #![feature(rand)]
44-
/// use std::rand;
45-
/// use std::rand::distributions::{IndependentSample, Gamma};
46-
///
47-
/// let gamma = Gamma::new(2.0, 5.0);
48-
/// let v = gamma.ind_sample(&mut rand::thread_rng());
49-
/// println!("{} is from a Gamma(2, 5) distribution", v);
50-
/// ```
51-
///
5240
/// [1]: George Marsaglia and Wai Wan Tsang. 2000. "A Simple Method
5341
/// for Generating Gamma Variables" *ACM Trans. Math. Softw.* 26, 3
5442
/// (September 2000),
@@ -184,18 +172,6 @@ impl IndependentSample<f64> for GammaLargeShape {
184172
/// of `k` independent standard normal random variables. For other
185173
/// `k`, this uses the equivalent characterisation `χ²(k) = Gamma(k/2,
186174
/// 2)`.
187-
///
188-
/// # Examples
189-
///
190-
/// ```
191-
/// # #![feature(rand)]
192-
/// use std::rand;
193-
/// use std::rand::distributions::{ChiSquared, IndependentSample};
194-
///
195-
/// let chi = ChiSquared::new(11.0);
196-
/// let v = chi.ind_sample(&mut rand::thread_rng());
197-
/// println!("{} is from a χ²(11) distribution", v)
198-
/// ```
199175
pub struct ChiSquared {
200176
repr: ChiSquaredRepr,
201177
}
@@ -242,18 +218,6 @@ impl IndependentSample<f64> for ChiSquared {
242218
/// This distribution is equivalent to the ratio of two normalised
243219
/// chi-squared distributions, that is, `F(m,n) = (χ²(m)/m) /
244220
/// (χ²(n)/n)`.
245-
///
246-
/// # Examples
247-
///
248-
/// ```
249-
/// # #![feature(rand)]
250-
/// use std::rand;
251-
/// use std::rand::distributions::{FisherF, IndependentSample};
252-
///
253-
/// let f = FisherF::new(2.0, 32.0);
254-
/// let v = f.ind_sample(&mut rand::thread_rng());
255-
/// println!("{} is from an F(2, 32) distribution", v)
256-
/// ```
257221
pub struct FisherF {
258222
numer: ChiSquared,
259223
denom: ChiSquared,
@@ -287,18 +251,6 @@ impl IndependentSample<f64> for FisherF {
287251

288252
/// The Student t distribution, `t(nu)`, where `nu` is the degrees of
289253
/// freedom.
290-
///
291-
/// # Examples
292-
///
293-
/// ```
294-
/// # #![feature(rand)]
295-
/// use std::rand;
296-
/// use std::rand::distributions::{StudentT, IndependentSample};
297-
///
298-
/// let t = StudentT::new(11.0);
299-
/// let v = t.ind_sample(&mut rand::thread_rng());
300-
/// println!("{} is from a t(11) distribution", v)
301-
/// ```
302254
pub struct StudentT {
303255
chi: ChiSquared,
304256
dof: f64

src/librand/distributions/mod.rs

-18
Original file line numberDiff line numberDiff line change
@@ -90,24 +90,6 @@ pub struct Weighted<T> {
9090
/// `IndependentSample` traits. Note that `&T` is (cheaply) `Clone` for
9191
/// all `T`, as is `usize`, so one can store references or indices into
9292
/// another vector.
93-
///
94-
/// # Examples
95-
///
96-
/// ```
97-
/// # #![feature(rand)]
98-
/// use std::rand;
99-
/// use std::rand::distributions::{Weighted, WeightedChoice, IndependentSample};
100-
///
101-
/// let mut items = vec!(Weighted { weight: 2, item: 'a' },
102-
/// Weighted { weight: 4, item: 'b' },
103-
/// Weighted { weight: 1, item: 'c' });
104-
/// let wc = WeightedChoice::new(&mut items[..]);
105-
/// let mut rng = rand::thread_rng();
106-
/// for _ in 0..16 {
107-
/// // on average prints 'a' 4 times, 'b' 8 and 'c' twice.
108-
/// println!("{}", wc.ind_sample(&mut rng));
109-
/// }
110-
/// ```
11193
pub struct WeightedChoice<'a, T:'a> {
11294
items: &'a mut [Weighted<T>],
11395
weight_range: Range<usize>

src/librand/distributions/normal.rs

-26
Original file line numberDiff line numberDiff line change
@@ -72,19 +72,6 @@ impl Rand for StandardNormal {
7272
///
7373
/// This uses the ZIGNOR variant of the Ziggurat method, see
7474
/// `StandardNormal` for more details.
75-
///
76-
/// # Examples
77-
///
78-
/// ```
79-
/// # #![feature(rand)]
80-
/// use std::rand;
81-
/// use std::rand::distributions::{Normal, IndependentSample};
82-
///
83-
/// // mean 2, standard deviation 3
84-
/// let normal = Normal::new(2.0, 3.0);
85-
/// let v = normal.ind_sample(&mut rand::thread_rng());
86-
/// println!("{} is from a N(2, 9) distribution", v)
87-
/// ```
8875
#[derive(Copy, Clone)]
8976
pub struct Normal {
9077
mean: f64,
@@ -121,19 +108,6 @@ impl IndependentSample<f64> for Normal {
121108
///
122109
/// If `X` is log-normal distributed, then `ln(X)` is `N(mean,
123110
/// std_dev**2)` distributed.
124-
///
125-
/// # Examples
126-
///
127-
/// ```
128-
/// # #![feature(rand)]
129-
/// use std::rand;
130-
/// use std::rand::distributions::{LogNormal, IndependentSample};
131-
///
132-
/// // mean 2, standard deviation 3
133-
/// let log_normal = LogNormal::new(2.0, 3.0);
134-
/// let v = log_normal.ind_sample(&mut rand::thread_rng());
135-
/// println!("{} is from an ln N(2, 9) distribution", v)
136-
/// ```
137111
#[derive(Copy, Clone)]
138112
pub struct LogNormal {
139113
norm: Normal

src/librand/distributions/range.rs

-17
Original file line numberDiff line numberDiff line change
@@ -32,23 +32,6 @@ use distributions::{Sample, IndependentSample};
3232
/// including `high`, but this may be very difficult. All the
3333
/// primitive integer types satisfy this property, and the float types
3434
/// normally satisfy it, but rounding may mean `high` can occur.
35-
///
36-
/// # Examples
37-
///
38-
/// ```
39-
/// # #![feature(rand)]
40-
/// use std::rand::distributions::{IndependentSample, Range};
41-
///
42-
/// fn main() {
43-
/// let between = Range::new(10, 10000);
44-
/// let mut rng = std::rand::thread_rng();
45-
/// let mut sum = 0;
46-
/// for _ in 0..1000 {
47-
/// sum += between.ind_sample(&mut rng);
48-
/// }
49-
/// println!("{}", sum);
50-
/// }
51-
/// ```
5235
pub struct Range<X> {
5336
low: X,
5437
range: X,

src/librand/lib.rs

-139
Original file line numberDiff line numberDiff line change
@@ -143,17 +143,6 @@ pub trait Rng : Sized {
143143
/// with new data, and may panic if this is impossible
144144
/// (e.g. reading past the end of a file that is being used as the
145145
/// source of randomness).
146-
///
147-
/// # Examples
148-
///
149-
/// ```
150-
/// # #![feature(rand, core)]
151-
/// use std::rand::{thread_rng, Rng};
152-
///
153-
/// let mut v = [0; 13579];
154-
/// thread_rng().fill_bytes(&mut v);
155-
/// println!("{:?}", &v[..]);
156-
/// ```
157146
fn fill_bytes(&mut self, dest: &mut [u8]) {
158147
// this could, in theory, be done by transmuting dest to a
159148
// [u64], but this is (1) likely to be undefined behaviour for
@@ -179,38 +168,13 @@ pub trait Rng : Sized {
179168
}
180169

181170
/// Return a random value of a `Rand` type.
182-
///
183-
/// # Examples
184-
///
185-
/// ```
186-
/// # #![feature(rand)]
187-
/// use std::rand::{thread_rng, Rng};
188-
///
189-
/// let mut rng = thread_rng();
190-
/// let x: usize = rng.gen();
191-
/// println!("{}", x);
192-
/// println!("{:?}", rng.gen::<(f64, bool)>());
193-
/// ```
194171
#[inline(always)]
195172
fn gen<T: Rand>(&mut self) -> T {
196173
Rand::rand(self)
197174
}
198175

199176
/// Return an iterator that will yield an infinite number of randomly
200177
/// generated items.
201-
///
202-
/// # Examples
203-
///
204-
/// ```
205-
/// # #![feature(rand)]
206-
/// use std::rand::{thread_rng, Rng};
207-
///
208-
/// let mut rng = thread_rng();
209-
/// let x = rng.gen_iter::<usize>().take(10).collect::<Vec<usize>>();
210-
/// println!("{:?}", x);
211-
/// println!("{:?}", rng.gen_iter::<(f64, bool)>().take(5)
212-
/// .collect::<Vec<(f64, bool)>>());
213-
/// ```
214178
fn gen_iter<'a, T: Rand>(&'a mut self) -> Generator<'a, T, Self> {
215179
Generator { rng: self, _marker: PhantomData }
216180
}
@@ -226,69 +190,24 @@ pub trait Rng : Sized {
226190
/// # Panics
227191
///
228192
/// Panics if `low >= high`.
229-
///
230-
/// # Examples
231-
///
232-
/// ```
233-
/// # #![feature(rand)]
234-
/// use std::rand::{thread_rng, Rng};
235-
///
236-
/// let mut rng = thread_rng();
237-
/// let n: usize = rng.gen_range(0, 10);
238-
/// println!("{}", n);
239-
/// let m: f64 = rng.gen_range(-40.0f64, 1.3e5f64);
240-
/// println!("{}", m);
241-
/// ```
242193
fn gen_range<T: PartialOrd + SampleRange>(&mut self, low: T, high: T) -> T {
243194
assert!(low < high, "Rng.gen_range called with low >= high");
244195
Range::new(low, high).ind_sample(self)
245196
}
246197

247198
/// Return a bool with a 1 in n chance of true
248-
///
249-
/// # Examples
250-
///
251-
/// ```
252-
/// # #![feature(rand)]
253-
/// use std::rand::{thread_rng, Rng};
254-
///
255-
/// let mut rng = thread_rng();
256-
/// println!("{}", rng.gen_weighted_bool(3));
257-
/// ```
258199
fn gen_weighted_bool(&mut self, n: usize) -> bool {
259200
n <= 1 || self.gen_range(0, n) == 0
260201
}
261202

262203
/// Return an iterator of random characters from the set A-Z,a-z,0-9.
263-
///
264-
/// # Examples
265-
///
266-
/// ```
267-
/// # #![feature(rand)]
268-
/// use std::rand::{thread_rng, Rng};
269-
///
270-
/// let s: String = thread_rng().gen_ascii_chars().take(10).collect();
271-
/// println!("{}", s);
272-
/// ```
273204
fn gen_ascii_chars<'a>(&'a mut self) -> AsciiGenerator<'a, Self> {
274205
AsciiGenerator { rng: self }
275206
}
276207

277208
/// Return a random element from `values`.
278209
///
279210
/// Return `None` if `values` is empty.
280-
///
281-
/// # Examples
282-
///
283-
/// ```
284-
/// # #![feature(rand)]
285-
/// use std::rand::{thread_rng, Rng};
286-
///
287-
/// let choices = [1, 2, 4, 8, 16, 32];
288-
/// let mut rng = thread_rng();
289-
/// println!("{:?}", rng.choose(&choices));
290-
/// assert_eq!(rng.choose(&choices[..0]), None);
291-
/// ```
292211
fn choose<'a, T>(&mut self, values: &'a [T]) -> Option<&'a T> {
293212
if values.is_empty() {
294213
None
@@ -298,20 +217,6 @@ pub trait Rng : Sized {
298217
}
299218

300219
/// Shuffle a mutable slice in place.
301-
///
302-
/// # Examples
303-
///
304-
/// ```
305-
/// # #![feature(rand, core)]
306-
/// use std::rand::{thread_rng, Rng};
307-
///
308-
/// let mut rng = thread_rng();
309-
/// let mut y = [1, 2, 3];
310-
/// rng.shuffle(&mut y);
311-
/// println!("{:?}", y);
312-
/// rng.shuffle(&mut y);
313-
/// println!("{:?}", y);
314-
/// ```
315220
fn shuffle<T>(&mut self, values: &mut [T]) {
316221
let mut i = values.len();
317222
while i >= 2 {
@@ -362,33 +267,9 @@ impl<'a, R: Rng> Iterator for AsciiGenerator<'a, R> {
362267
/// the same stream of randomness multiple times.
363268
pub trait SeedableRng<Seed>: Rng {
364269
/// Reseed an RNG with the given seed.
365-
///
366-
/// # Examples
367-
///
368-
/// ```
369-
/// # #![feature(rand)]
370-
/// use std::rand::{Rng, SeedableRng, StdRng};
371-
///
372-
/// let seed: &[_] = &[1, 2, 3, 4];
373-
/// let mut rng: StdRng = SeedableRng::from_seed(seed);
374-
/// println!("{}", rng.gen::<f64>());
375-
/// rng.reseed(&[5, 6, 7, 8]);
376-
/// println!("{}", rng.gen::<f64>());
377-
/// ```
378270
fn reseed(&mut self, Seed);
379271

380272
/// Create a new RNG with the given seed.
381-
///
382-
/// # Examples
383-
///
384-
/// ```
385-
/// # #![feature(rand)]
386-
/// use std::rand::{Rng, SeedableRng, StdRng};
387-
///
388-
/// let seed: &[_] = &[1, 2, 3, 4];
389-
/// let mut rng: StdRng = SeedableRng::from_seed(seed);
390-
/// println!("{}", rng.gen::<f64>());
391-
/// ```
392273
fn from_seed(seed: Seed) -> Self;
393274
}
394275

@@ -484,16 +365,6 @@ impl Rand for XorShiftRng {
484365
/// Use `Closed01` for the closed interval `[0,1]`, and the default
485366
/// `Rand` implementation for `f32` and `f64` for the half-open
486367
/// `[0,1)`.
487-
///
488-
/// # Examples
489-
///
490-
/// ```
491-
/// # #![feature(rand)]
492-
/// use std::rand::{random, Open01};
493-
///
494-
/// let Open01(val) = random::<Open01<f32>>();
495-
/// println!("f32 from (0,1): {}", val);
496-
/// ```
497368
pub struct Open01<F>(pub F);
498369

499370
/// A wrapper for generating floating point numbers uniformly in the
@@ -502,16 +373,6 @@ pub struct Open01<F>(pub F);
502373
/// Use `Open01` for the closed interval `(0,1)`, and the default
503374
/// `Rand` implementation of `f32` and `f64` for the half-open
504375
/// `[0,1)`.
505-
///
506-
/// # Examples
507-
///
508-
/// ```
509-
/// # #![feature(rand)]
510-
/// use std::rand::{random, Closed01};
511-
///
512-
/// let Closed01(val) = random::<Closed01<f32>>();
513-
/// println!("f32 from [0,1]: {}", val);
514-
/// ```
515376
pub struct Closed01<F>(pub F);
516377

517378
#[cfg(test)]

0 commit comments

Comments
 (0)