Skip to content

Commit 07fb949

Browse files
committed
---
yaml --- r: 187004 b: refs/heads/try c: 199b992 h: refs/heads/master v: v3
1 parent 223dc08 commit 07fb949

File tree

3 files changed

+13
-4
lines changed

3 files changed

+13
-4
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
refs/heads/master: b4c965ee803a4521d8b4575f634e036f93e408f3
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: 3a96d6a9818fe2affc98a187fb1065120458cee9
5-
refs/heads/try: 2953710d26515ee2832ae6f705f51d00526fa018
5+
refs/heads/try: 199b992e6306ead7a2be1e086768879983c08a20
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/dist-snap: ba4081a5a8573875fed17545846f6f6902c8ba8d
88
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596

branches/try/src/librand/distributions/mod.rs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121

2222
use core::prelude::*;
2323
use core::num::{Float, Int};
24+
use core::marker::PhantomData;
2425

2526
use {Rng, Rand};
2627

@@ -56,7 +57,13 @@ pub trait IndependentSample<Support>: Sample<Support> {
5657

5758
/// A wrapper for generating types that implement `Rand` via the
5859
/// `Sample` & `IndependentSample` traits.
59-
pub struct RandSample<Sup>;
60+
pub struct RandSample<Sup> { _marker: PhantomData<Sup> }
61+
62+
impl<Sup> RandSample<Sup> {
63+
pub fn new() -> RandSample<Sup> {
64+
RandSample { _marker: PhantomData }
65+
}
66+
}
6067

6168
impl<Sup: Rand> Sample<Sup> for RandSample<Sup> {
6269
fn sample<R: Rng>(&mut self, rng: &mut R) -> Sup { self.ind_sample(rng) }
@@ -285,7 +292,7 @@ mod tests {
285292

286293
#[test]
287294
fn test_rand_sample() {
288-
let mut rand_sample = RandSample::<ConstRand>;
295+
let mut rand_sample = RandSample::<ConstRand>::new();
289296

290297
assert_eq!(rand_sample.sample(&mut ::test::rng()), ConstRand(0));
291298
assert_eq!(rand_sample.ind_sample(&mut ::test::rng()), ConstRand(0));

branches/try/src/librand/lib.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ extern crate core;
4141
#[cfg(test)] #[macro_use] extern crate log;
4242

4343
use core::prelude::*;
44+
use core::marker::PhantomData;
4445

4546
pub use isaac::{IsaacRng, Isaac64Rng};
4647
pub use chacha::ChaChaRng;
@@ -206,7 +207,7 @@ pub trait Rng : Sized {
206207
/// .collect::<Vec<(f64, bool)>>());
207208
/// ```
208209
fn gen_iter<'a, T: Rand>(&'a mut self) -> Generator<'a, T, Self> {
209-
Generator { rng: self }
210+
Generator { rng: self, _marker: PhantomData }
210211
}
211212

212213
/// Generate a random value in the range [`low`, `high`).
@@ -317,6 +318,7 @@ pub trait Rng : Sized {
317318
/// This iterator is created via the `gen_iter` method on `Rng`.
318319
pub struct Generator<'a, T, R:'a> {
319320
rng: &'a mut R,
321+
_marker: PhantomData<T>
320322
}
321323

322324
impl<'a, T: Rand, R: Rng> Iterator for Generator<'a, T, R> {

0 commit comments

Comments
 (0)