Skip to content

Commit

Permalink
Expand large seed example so it compiles
Browse files Browse the repository at this point in the history
  • Loading branch information
vks committed Apr 10, 2018
1 parent dce7510 commit b75cfb5
Showing 1 changed file with 24 additions and 5 deletions.
29 changes: 24 additions & 5 deletions rand_core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -294,16 +294,35 @@ pub trait SeedableRng: Sized {
/// `SeedableRng` for RNGs with such large seeds, the newtype pattern can be
/// used:
///
/// ```ignore
/// pub struct MyRngSeed(pub [u8; N]);
/// ```
/// use rand_core::SeedableRng;
///
/// pub struct MyRngSeed(pub [u8; 64]);
/// pub struct MyRng(MyRngSeed);
///
/// impl Default for MyRngSeed { ... }
/// impl AsMut<u8> for MyRngSeed { ... }
/// impl Default for MyRngSeed {
/// fn default() -> MyRngSeed {
/// MyRngSeed([
/// 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
/// 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
/// 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
/// 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
/// ])
/// }
/// }
///
/// impl AsMut<[u8]> for MyRngSeed {
/// fn as_mut(&mut self) -> &mut [u8] {
/// &mut self.0
/// }
/// }
///
/// impl SeedableRng for MyRng {
/// type Seed = MyRngSeed;
///
/// fn from_seed(seed: MyRngSeed) -> MyRng { ... }
/// fn from_seed(seed: MyRngSeed) -> MyRng {
/// MyRng(MyRngSeed)
/// }
/// }
/// ```
type Seed: Sized + Default + AsMut<[u8]>;
Expand Down

0 comments on commit b75cfb5

Please sign in to comment.