Skip to content

Commit 02cf375

Browse files
committed
rand: Switch field privacy as necessary
1 parent 14587f8 commit 02cf375

File tree

10 files changed

+45
-43
lines changed

10 files changed

+45
-43
lines changed

src/librand/distributions/exponential.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ impl Rand for Exp1 {
6666
/// ```
6767
pub struct Exp {
6868
/// `lambda` stored as `1/lambda`, since this is what we scale by.
69-
priv lambda_inverse: f64
69+
lambda_inverse: f64
7070
}
7171

7272
impl Exp {

src/librand/distributions/gamma.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -236,11 +236,11 @@ impl IndependentSample<f64> for ChiSquared {
236236
/// println!("{} is from an F(2, 32) distribution", v)
237237
/// ```
238238
pub struct FisherF {
239-
priv numer: ChiSquared,
240-
priv denom: ChiSquared,
239+
numer: ChiSquared,
240+
denom: ChiSquared,
241241
// denom_dof / numer_dof so that this can just be a straight
242242
// multiplication, rather than a division.
243-
priv dof_ratio: f64,
243+
dof_ratio: f64,
244244
}
245245

246246
impl FisherF {
@@ -279,8 +279,8 @@ impl IndependentSample<f64> for FisherF {
279279
/// println!("{} is from a t(11) distribution", v)
280280
/// ```
281281
pub struct StudentT {
282-
priv chi: ChiSquared,
283-
priv dof: f64
282+
chi: ChiSquared,
283+
dof: f64
284284
}
285285

286286
impl StudentT {

src/librand/distributions/mod.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -71,9 +71,9 @@ impl<Sup: Rand> IndependentSample<Sup> for RandSample<Sup> {
7171
/// A value with a particular weight for use with `WeightedChoice`.
7272
pub struct Weighted<T> {
7373
/// The numerical weight of this item
74-
weight: uint,
74+
pub weight: uint,
7575
/// The actual item which is being weighted
76-
item: T,
76+
pub item: T,
7777
}
7878

7979
/// A distribution that selects from a finite collection of weighted items.
@@ -101,8 +101,8 @@ pub struct Weighted<T> {
101101
/// }
102102
/// ```
103103
pub struct WeightedChoice<T> {
104-
priv items: ~[Weighted<T>],
105-
priv weight_range: Range<uint>
104+
pub items: ~[Weighted<T>],
105+
pub weight_range: Range<uint>
106106
}
107107

108108
impl<T: Clone> WeightedChoice<T> {

src/librand/distributions/normal.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,8 @@ impl Rand for StandardNormal {
8282
/// println!("{} is from a N(2, 9) distribution", v)
8383
/// ```
8484
pub struct Normal {
85-
priv mean: f64,
86-
priv std_dev: f64
85+
mean: f64,
86+
std_dev: f64,
8787
}
8888

8989
impl Normal {
@@ -124,7 +124,7 @@ impl IndependentSample<f64> for Normal {
124124
/// println!("{} is from an ln N(2, 9) distribution", v)
125125
/// ```
126126
pub struct LogNormal {
127-
priv norm: Normal
127+
norm: Normal
128128
}
129129

130130
impl LogNormal {

src/librand/distributions/range.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,9 @@ use distributions::{Sample, IndependentSample};
4646
/// }
4747
/// ```
4848
pub struct Range<X> {
49-
priv low: X,
50-
priv range: X,
51-
priv accept_zone: X
49+
low: X,
50+
range: X,
51+
accept_zone: X
5252
}
5353

5454
impl<X: SampleRange + Ord> Range<X> {

src/librand/isaac.rs

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,12 @@ static RAND_SIZE: u32 = 1 << RAND_SIZE_LEN;
2828
/// [1]: Bob Jenkins, [*ISAAC: A fast cryptographic random number
2929
/// generator*](http://www.burtleburtle.net/bob/rand/isaacafa.html)
3030
pub struct IsaacRng {
31-
priv cnt: u32,
32-
priv rsl: [u32, .. RAND_SIZE],
33-
priv mem: [u32, .. RAND_SIZE],
34-
priv a: u32,
35-
priv b: u32,
36-
priv c: u32
31+
cnt: u32,
32+
rsl: [u32, .. RAND_SIZE],
33+
mem: [u32, .. RAND_SIZE],
34+
a: u32,
35+
b: u32,
36+
c: u32
3737
}
3838
static EMPTY: IsaacRng = IsaacRng {
3939
cnt: 0,
@@ -231,12 +231,12 @@ static RAND_SIZE_64: uint = 1 << RAND_SIZE_64_LEN;
231231
/// [1]: Bob Jenkins, [*ISAAC: A fast cryptographic random number
232232
/// generator*](http://www.burtleburtle.net/bob/rand/isaacafa.html)
233233
pub struct Isaac64Rng {
234-
priv cnt: uint,
235-
priv rsl: [u64, .. RAND_SIZE_64],
236-
priv mem: [u64, .. RAND_SIZE_64],
237-
priv a: u64,
238-
priv b: u64,
239-
priv c: u64,
234+
cnt: uint,
235+
rsl: [u64, .. RAND_SIZE_64],
236+
mem: [u64, .. RAND_SIZE_64],
237+
a: u64,
238+
b: u64,
239+
c: u64,
240240
}
241241

242242
static EMPTY_64: Isaac64Rng = Isaac64Rng {

src/librand/lib.rs

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,8 @@ println!("{:?}", tuple_ptr)
7272

7373
#![feature(macro_rules, managed_boxes, phase)]
7474

75+
#![allow(visible_private_types)] // NOTE: remove after a stage0 snap
76+
7577
#[cfg(test)]
7678
#[phase(syntax, link)] extern crate log;
7779

@@ -407,12 +409,12 @@ pub fn rng() -> StdRng {
407409
/// The standard RNG. This is designed to be efficient on the current
408410
/// platform.
409411
#[cfg(not(target_word_size="64"))]
410-
pub struct StdRng { priv rng: IsaacRng }
412+
pub struct StdRng { rng: IsaacRng }
411413

412414
/// The standard RNG. This is designed to be efficient on the current
413415
/// platform.
414416
#[cfg(target_word_size="64")]
415-
pub struct StdRng { priv rng: Isaac64Rng }
417+
pub struct StdRng { rng: Isaac64Rng }
416418

417419
impl StdRng {
418420
/// Create a randomly seeded instance of `StdRng`.
@@ -489,10 +491,10 @@ pub fn weak_rng() -> XorShiftRng {
489491
/// RNGs"](http://www.jstatsoft.org/v08/i14/paper). *Journal of
490492
/// Statistical Software*. Vol. 8 (Issue 14).
491493
pub struct XorShiftRng {
492-
priv x: u32,
493-
priv y: u32,
494-
priv z: u32,
495-
priv w: u32,
494+
x: u32,
495+
y: u32,
496+
z: u32,
497+
w: u32,
496498
}
497499

498500
impl Rng for XorShiftRng {
@@ -573,8 +575,8 @@ pub struct TaskRng {
573575
// The use of unsafe code here is OK if the invariants above are
574576
// satisfied; and it allows us to avoid (unnecessarily) using a
575577
// GC'd or RC'd pointer.
576-
priv rng: *mut TaskRngInner,
577-
priv marker: marker::NoSend,
578+
rng: *mut TaskRngInner,
579+
marker: marker::NoSend,
578580
}
579581

580582
// used to make space in TLS for a random number generator

src/librand/os.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ mod imp {
3030
/// This does not block.
3131
#[cfg(unix)]
3232
pub struct OSRng {
33-
priv inner: ReaderRng<File>
33+
inner: ReaderRng<File>
3434
}
3535

3636
impl OSRng {
@@ -77,7 +77,7 @@ mod imp {
7777
///
7878
/// This does not block.
7979
pub struct OSRng {
80-
priv hcryptprov: HCRYPTPROV
80+
hcryptprov: HCRYPTPROV
8181
}
8282

8383
static PROV_RSA_FULL: DWORD = 1;

src/librand/reader.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ use Rng;
2727
/// println!("{:x}", rng.gen::<uint>());
2828
/// ```
2929
pub struct ReaderRng<R> {
30-
priv reader: R
30+
reader: R
3131
}
3232

3333
impl<R: Reader> ReaderRng<R> {

src/librand/reseeding.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,11 @@ static DEFAULT_GENERATION_THRESHOLD: uint = 32 * 1024;
2121
/// A wrapper around any RNG which reseeds the underlying RNG after it
2222
/// has generated a certain number of random bytes.
2323
pub struct ReseedingRng<R, Rsdr> {
24-
priv rng: R,
25-
priv generation_threshold: uint,
26-
priv bytes_generated: uint,
24+
rng: R,
25+
generation_threshold: uint,
26+
bytes_generated: uint,
2727
/// Controls the behaviour when reseeding the RNG.
28-
reseeder: Rsdr
28+
pub reseeder: Rsdr,
2929
}
3030

3131
impl<R: Rng, Rsdr: Reseeder<R>> ReseedingRng<R, Rsdr> {

0 commit comments

Comments
 (0)