diff options
| author | Jorge Aparicio <japaricious@gmail.com> | 2014-12-15 15:35:34 -0500 |
|---|---|---|
| committer | Jorge Aparicio <japaricious@gmail.com> | 2014-12-15 15:35:34 -0500 |
| commit | c3778fae6f57d30381476ea0110cb445e52b407a (patch) | |
| tree | 75b07a60b6c80ab45427b3f668fb85fb596d324e /src/libstd | |
| parent | 556d971f83ea5950444b0a5b5392cd0040f077f6 (diff) | |
| download | rust-c3778fae6f57d30381476ea0110cb445e52b407a.tar.gz rust-c3778fae6f57d30381476ea0110cb445e52b407a.zip | |
libstd: add a dummy field to `OsRng` to avoid out of module construction
Diffstat (limited to 'src/libstd')
| -rw-r--r-- | src/libstd/rand/os.rs | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/src/libstd/rand/os.rs b/src/libstd/rand/os.rs index c0eebe135c3..c1e42660269 100644 --- a/src/libstd/rand/os.rs +++ b/src/libstd/rand/os.rs @@ -187,7 +187,10 @@ mod imp { /// - iOS: calls SecRandomCopyBytes as /dev/(u)random is sandboxed /// This does not block. #[allow(missing_copy_implementations)] - pub struct OsRng; + pub struct OsRng { + // dummy field to ensure that this struct cannot be constructed outside of this module + _dummy: (), + } #[repr(C)] struct SecRandom; @@ -204,7 +207,7 @@ mod imp { impl OsRng { /// Create a new `OsRng`. pub fn new() -> IoResult<OsRng> { - Ok(OsRng) + Ok(OsRng { _dummy: () }) } } |
