summary refs log tree commit diff
path: root/src/libstd
diff options
context:
space:
mode:
authorPiotr Jawniak <sawyer47@gmail.com>2014-05-30 06:37:31 +0200
committerPiotr Jawniak <sawyer47@gmail.com>2014-05-30 06:37:31 +0200
commitaa7b215f04962b307b86b2160da4899a64ea35a0 (patch)
treeef90d91cabaa192eb1f291b2053e3b9dc976a375 /src/libstd
parent6510527e153b32b1006aee358d30ea8f62e7e02a (diff)
downloadrust-aa7b215f04962b307b86b2160da4899a64ea35a0.tar.gz
rust-aa7b215f04962b307b86b2160da4899a64ea35a0.zip
Rename OSRng to OsRng
According to Rust's style guide acronyms in type names should be
CamelCase.

[breaking-change]
Diffstat (limited to 'src/libstd')
-rw-r--r--src/libstd/rand/mod.rs16
-rw-r--r--src/libstd/rand/os.rs34
2 files changed, 25 insertions, 25 deletions
diff --git a/src/libstd/rand/mod.rs b/src/libstd/rand/mod.rs
index c7ae6331d11..61a2ffd383d 100644
--- a/src/libstd/rand/mod.rs
+++ b/src/libstd/rand/mod.rs
@@ -32,7 +32,7 @@ after generating 32 KiB of random data.
 # Cryptographic security
 
 An application that requires an entropy source for cryptographic purposes
-must use `OSRng`, which reads randomness from the source that the operating
+must use `OsRng`, which reads randomness from the source that the operating
 system provides (e.g. `/dev/urandom` on Unixes or `CryptGenRandom()` on Windows).
 The other random number generators provided by this module are not suitable
 for such purposes.
@@ -91,7 +91,7 @@ use IsaacWordRng = core_rand::Isaac64Rng;
 pub use core_rand::{Rand, Rng, SeedableRng, Open01, Closed01};
 pub use core_rand::{XorShiftRng, IsaacRng, Isaac64Rng};
 pub use core_rand::{distributions, reseeding};
-pub use rand::os::OSRng;
+pub use rand::os::OsRng;
 
 pub mod os;
 pub mod reader;
@@ -113,7 +113,7 @@ impl StdRng {
     /// Reading the randomness from the OS may fail, and any error is
     /// propagated via the `IoResult` return value.
     pub fn new() -> IoResult<StdRng> {
-        OSRng::new().map(|mut r| StdRng { rng: r.gen() })
+        OsRng::new().map(|mut r| StdRng { rng: r.gen() })
     }
 }
 
@@ -151,7 +151,7 @@ impl<'a> SeedableRng<&'a [uint]> for StdRng {
 /// This will read randomness from the operating system to seed the
 /// generator.
 pub fn weak_rng() -> XorShiftRng {
-    match OSRng::new() {
+    match OsRng::new() {
         Ok(mut r) => r.gen(),
         Err(e) => fail!("weak_rng: failed to create seeded RNG: {}", e)
     }
@@ -467,12 +467,12 @@ mod bench {
 
     use self::test::Bencher;
     use super::{XorShiftRng, StdRng, IsaacRng, Isaac64Rng, Rng, RAND_BENCH_N};
-    use super::{OSRng, weak_rng};
+    use super::{OsRng, weak_rng};
     use mem::size_of;
 
     #[bench]
     fn rand_xorshift(b: &mut Bencher) {
-        let mut rng: XorShiftRng = OSRng::new().unwrap().gen();
+        let mut rng: XorShiftRng = OsRng::new().unwrap().gen();
         b.iter(|| {
             for _ in range(0, RAND_BENCH_N) {
                 rng.gen::<uint>();
@@ -483,7 +483,7 @@ mod bench {
 
     #[bench]
     fn rand_isaac(b: &mut Bencher) {
-        let mut rng: IsaacRng = OSRng::new().unwrap().gen();
+        let mut rng: IsaacRng = OsRng::new().unwrap().gen();
         b.iter(|| {
             for _ in range(0, RAND_BENCH_N) {
                 rng.gen::<uint>();
@@ -494,7 +494,7 @@ mod bench {
 
     #[bench]
     fn rand_isaac64(b: &mut Bencher) {
-        let mut rng: Isaac64Rng = OSRng::new().unwrap().gen();
+        let mut rng: Isaac64Rng = OsRng::new().unwrap().gen();
         b.iter(|| {
             for _ in range(0, RAND_BENCH_N) {
                 rng.gen::<uint>();
diff --git a/src/libstd/rand/os.rs b/src/libstd/rand/os.rs
index ea4d7ad25a3..3a6c0124ee0 100644
--- a/src/libstd/rand/os.rs
+++ b/src/libstd/rand/os.rs
@@ -11,7 +11,7 @@
 //! Interfaces to the operating system provided random number
 //! generators.
 
-pub use self::imp::OSRng;
+pub use self::imp::OsRng;
 
 #[cfg(unix)]
 mod imp {
@@ -31,21 +31,21 @@ mod imp {
     ///
     /// This does not block.
     #[cfg(unix)]
-    pub struct OSRng {
+    pub struct OsRng {
         inner: ReaderRng<File>
     }
 
-    impl OSRng {
-        /// Create a new `OSRng`.
-        pub fn new() -> IoResult<OSRng> {
+    impl OsRng {
+        /// Create a new `OsRng`.
+        pub fn new() -> IoResult<OsRng> {
             let reader = try!(File::open(&Path::new("/dev/urandom")));
             let reader_rng = ReaderRng::new(reader);
 
-            Ok(OSRng { inner: reader_rng })
+            Ok(OsRng { inner: reader_rng })
         }
     }
 
-    impl Rng for OSRng {
+    impl Rng for OsRng {
         fn next_u32(&mut self) -> u32 {
             self.inner.next_u32()
         }
@@ -84,7 +84,7 @@ mod imp {
     ///   service provider with the `PROV_RSA_FULL` type.
     ///
     /// This does not block.
-    pub struct OSRng {
+    pub struct OsRng {
         hcryptprov: HCRYPTPROV
     }
 
@@ -105,9 +105,9 @@ mod imp {
         fn CryptReleaseContext(hProv: HCRYPTPROV, dwFlags: DWORD) -> BOOL;
     }
 
-    impl OSRng {
-        /// Create a new `OSRng`.
-        pub fn new() -> IoResult<OSRng> {
+    impl OsRng {
+        /// Create a new `OsRng`.
+        pub fn new() -> IoResult<OsRng> {
             let mut hcp = 0;
             let mut ret = unsafe {
                 CryptAcquireContextA(&mut hcp, 0 as LPCSTR, 0 as LPCSTR,
@@ -154,12 +154,12 @@ mod imp {
             if ret == 0 {
                 Err(IoError::last_error())
             } else {
-                Ok(OSRng { hcryptprov: hcp })
+                Ok(OsRng { hcryptprov: hcp })
             }
         }
     }
 
-    impl Rng for OSRng {
+    impl Rng for OsRng {
         fn next_u32(&mut self) -> u32 {
             let mut v = [0u8, .. 4];
             self.fill_bytes(v);
@@ -181,7 +181,7 @@ mod imp {
         }
     }
 
-    impl Drop for OSRng {
+    impl Drop for OsRng {
         fn drop(&mut self) {
             let ret = unsafe {
                 CryptReleaseContext(self.hcryptprov, 0)
@@ -197,13 +197,13 @@ mod imp {
 mod test {
     use prelude::*;
 
-    use super::OSRng;
+    use super::OsRng;
     use rand::Rng;
     use task;
 
     #[test]
     fn test_os_rng() {
-        let mut r = OSRng::new().unwrap();
+        let mut r = OsRng::new().unwrap();
 
         r.next_u32();
         r.next_u64();
@@ -225,7 +225,7 @@ mod test {
 
                 // deschedule to attempt to interleave things as much
                 // as possible (XXX: is this a good test?)
-                let mut r = OSRng::new().unwrap();
+                let mut r = OsRng::new().unwrap();
                 task::deschedule();
                 let mut v = [0u8, .. 1000];