Skip to content

Commit af7c030

Browse files
committed
auto merge of #14511 : Sawyer47/rust/osrng-rename, r=alexcrichton
According to Rust's style guide acronyms in type names should be CamelCase. [breaking-change]
2 parents d0b0f16 + aa7b215 commit af7c030

File tree

5 files changed

+30
-30
lines changed

5 files changed

+30
-30
lines changed

src/libgreen/sched.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -977,8 +977,8 @@ impl ClosureConverter for UnsafeTaskReceiver {
977977
// worry there.
978978
#[cfg(windows)]
979979
fn new_sched_rng() -> XorShiftRng {
980-
use std::rand::OSRng;
981-
match OSRng::new() {
980+
use std::rand::OsRng;
981+
match OsRng::new() {
982982
Ok(mut r) => r.gen(),
983983
Err(e) => {
984984
rtabort!("sched: failed to create seeded RNG: {}", e)

src/librand/isaac.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ static RAND_SIZE: u32 = 1 << RAND_SIZE_LEN;
2424
///
2525
/// The ISAAC algorithm is generally accepted as suitable for
2626
/// cryptographic purposes, but this implementation has not be
27-
/// verified as such. Prefer a generator like `OSRng` that defers to
27+
/// verified as such. Prefer a generator like `OsRng` that defers to
2828
/// the operating system for cases that need high security.
2929
///
3030
/// [1]: Bob Jenkins, [*ISAAC: A fast cryptographic random number
@@ -231,7 +231,7 @@ static RAND_SIZE_64: uint = 1 << RAND_SIZE_64_LEN;
231231
///
232232
/// The ISAAC algorithm is generally accepted as suitable for
233233
/// cryptographic purposes, but this implementation has not be
234-
/// verified as such. Prefer a generator like `OSRng` that defers to
234+
/// verified as such. Prefer a generator like `OsRng` that defers to
235235
/// the operating system for cases that need high security.
236236
///
237237
/// [1]: Bob Jenkins, [*ISAAC: A fast cryptographic random number

src/librand/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -333,7 +333,7 @@ pub trait SeedableRng<Seed>: Rng {
333333
///
334334
/// The Xorshift algorithm is not suitable for cryptographic purposes
335335
/// but is very fast. If you do not know for sure that it fits your
336-
/// requirements, use a more secure one such as `IsaacRng` or `OSRng`.
336+
/// requirements, use a more secure one such as `IsaacRng` or `OsRng`.
337337
///
338338
/// [1]: Marsaglia, George (July 2003). ["Xorshift
339339
/// RNGs"](http://www.jstatsoft.org/v08/i14/paper). *Journal of

src/libstd/rand/mod.rs

+8-8
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ after generating 32 KiB of random data.
3232
# Cryptographic security
3333
3434
An application that requires an entropy source for cryptographic purposes
35-
must use `OSRng`, which reads randomness from the source that the operating
35+
must use `OsRng`, which reads randomness from the source that the operating
3636
system provides (e.g. `/dev/urandom` on Unixes or `CryptGenRandom()` on Windows).
3737
The other random number generators provided by this module are not suitable
3838
for such purposes.
@@ -91,7 +91,7 @@ use IsaacWordRng = core_rand::Isaac64Rng;
9191
pub use core_rand::{Rand, Rng, SeedableRng, Open01, Closed01};
9292
pub use core_rand::{XorShiftRng, IsaacRng, Isaac64Rng};
9393
pub use core_rand::{distributions, reseeding};
94-
pub use rand::os::OSRng;
94+
pub use rand::os::OsRng;
9595

9696
pub mod os;
9797
pub mod reader;
@@ -113,7 +113,7 @@ impl StdRng {
113113
/// Reading the randomness from the OS may fail, and any error is
114114
/// propagated via the `IoResult` return value.
115115
pub fn new() -> IoResult<StdRng> {
116-
OSRng::new().map(|mut r| StdRng { rng: r.gen() })
116+
OsRng::new().map(|mut r| StdRng { rng: r.gen() })
117117
}
118118
}
119119

@@ -151,7 +151,7 @@ impl<'a> SeedableRng<&'a [uint]> for StdRng {
151151
/// This will read randomness from the operating system to seed the
152152
/// generator.
153153
pub fn weak_rng() -> XorShiftRng {
154-
match OSRng::new() {
154+
match OsRng::new() {
155155
Ok(mut r) => r.gen(),
156156
Err(e) => fail!("weak_rng: failed to create seeded RNG: {}", e)
157157
}
@@ -467,12 +467,12 @@ mod bench {
467467

468468
use self::test::Bencher;
469469
use super::{XorShiftRng, StdRng, IsaacRng, Isaac64Rng, Rng, RAND_BENCH_N};
470-
use super::{OSRng, weak_rng};
470+
use super::{OsRng, weak_rng};
471471
use mem::size_of;
472472

473473
#[bench]
474474
fn rand_xorshift(b: &mut Bencher) {
475-
let mut rng: XorShiftRng = OSRng::new().unwrap().gen();
475+
let mut rng: XorShiftRng = OsRng::new().unwrap().gen();
476476
b.iter(|| {
477477
for _ in range(0, RAND_BENCH_N) {
478478
rng.gen::<uint>();
@@ -483,7 +483,7 @@ mod bench {
483483

484484
#[bench]
485485
fn rand_isaac(b: &mut Bencher) {
486-
let mut rng: IsaacRng = OSRng::new().unwrap().gen();
486+
let mut rng: IsaacRng = OsRng::new().unwrap().gen();
487487
b.iter(|| {
488488
for _ in range(0, RAND_BENCH_N) {
489489
rng.gen::<uint>();
@@ -494,7 +494,7 @@ mod bench {
494494

495495
#[bench]
496496
fn rand_isaac64(b: &mut Bencher) {
497-
let mut rng: Isaac64Rng = OSRng::new().unwrap().gen();
497+
let mut rng: Isaac64Rng = OsRng::new().unwrap().gen();
498498
b.iter(|| {
499499
for _ in range(0, RAND_BENCH_N) {
500500
rng.gen::<uint>();

src/libstd/rand/os.rs

+17-17
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
//! Interfaces to the operating system provided random number
1212
//! generators.
1313
14-
pub use self::imp::OSRng;
14+
pub use self::imp::OsRng;
1515

1616
#[cfg(unix)]
1717
mod imp {
@@ -31,21 +31,21 @@ mod imp {
3131
///
3232
/// This does not block.
3333
#[cfg(unix)]
34-
pub struct OSRng {
34+
pub struct OsRng {
3535
inner: ReaderRng<File>
3636
}
3737

38-
impl OSRng {
39-
/// Create a new `OSRng`.
40-
pub fn new() -> IoResult<OSRng> {
38+
impl OsRng {
39+
/// Create a new `OsRng`.
40+
pub fn new() -> IoResult<OsRng> {
4141
let reader = try!(File::open(&Path::new("/dev/urandom")));
4242
let reader_rng = ReaderRng::new(reader);
4343

44-
Ok(OSRng { inner: reader_rng })
44+
Ok(OsRng { inner: reader_rng })
4545
}
4646
}
4747

48-
impl Rng for OSRng {
48+
impl Rng for OsRng {
4949
fn next_u32(&mut self) -> u32 {
5050
self.inner.next_u32()
5151
}
@@ -84,7 +84,7 @@ mod imp {
8484
/// service provider with the `PROV_RSA_FULL` type.
8585
///
8686
/// This does not block.
87-
pub struct OSRng {
87+
pub struct OsRng {
8888
hcryptprov: HCRYPTPROV
8989
}
9090

@@ -105,9 +105,9 @@ mod imp {
105105
fn CryptReleaseContext(hProv: HCRYPTPROV, dwFlags: DWORD) -> BOOL;
106106
}
107107

108-
impl OSRng {
109-
/// Create a new `OSRng`.
110-
pub fn new() -> IoResult<OSRng> {
108+
impl OsRng {
109+
/// Create a new `OsRng`.
110+
pub fn new() -> IoResult<OsRng> {
111111
let mut hcp = 0;
112112
let mut ret = unsafe {
113113
CryptAcquireContextA(&mut hcp, 0 as LPCSTR, 0 as LPCSTR,
@@ -154,12 +154,12 @@ mod imp {
154154
if ret == 0 {
155155
Err(IoError::last_error())
156156
} else {
157-
Ok(OSRng { hcryptprov: hcp })
157+
Ok(OsRng { hcryptprov: hcp })
158158
}
159159
}
160160
}
161161

162-
impl Rng for OSRng {
162+
impl Rng for OsRng {
163163
fn next_u32(&mut self) -> u32 {
164164
let mut v = [0u8, .. 4];
165165
self.fill_bytes(v);
@@ -181,7 +181,7 @@ mod imp {
181181
}
182182
}
183183

184-
impl Drop for OSRng {
184+
impl Drop for OsRng {
185185
fn drop(&mut self) {
186186
let ret = unsafe {
187187
CryptReleaseContext(self.hcryptprov, 0)
@@ -197,13 +197,13 @@ mod imp {
197197
mod test {
198198
use prelude::*;
199199

200-
use super::OSRng;
200+
use super::OsRng;
201201
use rand::Rng;
202202
use task;
203203

204204
#[test]
205205
fn test_os_rng() {
206-
let mut r = OSRng::new().unwrap();
206+
let mut r = OsRng::new().unwrap();
207207

208208
r.next_u32();
209209
r.next_u64();
@@ -225,7 +225,7 @@ mod test {
225225

226226
// deschedule to attempt to interleave things as much
227227
// as possible (XXX: is this a good test?)
228-
let mut r = OSRng::new().unwrap();
228+
let mut r = OsRng::new().unwrap();
229229
task::deschedule();
230230
let mut v = [0u8, .. 1000];
231231

0 commit comments

Comments
 (0)