Skip to content

Commit

Permalink
libstd: add a dummy field to OsRng to avoid out of module construction
Browse files Browse the repository at this point in the history
  • Loading branch information
Jorge Aparicio committed Dec 15, 2014
1 parent 556d971 commit c3778fa
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/libstd/rand/os.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -204,7 +207,7 @@ mod imp {
impl OsRng {
/// Create a new `OsRng`.
pub fn new() -> IoResult<OsRng> {
Ok(OsRng)
Ok(OsRng { _dummy: () })
}
}

Expand Down

0 comments on commit c3778fa

Please sign in to comment.