@@ -279,16 +279,15 @@ pub trait SeedableRng: Sized {
279
279
///
280
280
/// # Implementing `SeedableRng` for RNGs with large seeds
281
281
///
282
- /// Note that the required traits `core::default::Default` and
283
- /// `core::convert::AsMut<u8>` are not implemented for large arrays
284
- /// `[u8; N]` with `N` > 32. To be able to implement the traits required by
285
- /// `SeedableRng` for RNGs with such large seeds, the newtype pattern can be
286
- /// used:
282
+ /// Note that [`Default`] is not implemented for large arrays `[u8; N]` with
283
+ /// `N` > 32. To be able to implement the traits required by `SeedableRng`
284
+ /// for RNGs with such large seeds, the newtype pattern can be used:
287
285
///
288
286
/// ```
289
287
/// use rand_core::SeedableRng;
290
288
///
291
289
/// const N: usize = 64;
290
+ /// #[derive(Clone)]
292
291
/// pub struct MyRngSeed(pub [u8; N]);
293
292
/// # #[allow(dead_code)]
294
293
/// pub struct MyRng(MyRngSeed);
@@ -299,6 +298,12 @@ pub trait SeedableRng: Sized {
299
298
/// }
300
299
/// }
301
300
///
301
+ /// impl AsRef<[u8]> for MyRngSeed {
302
+ /// fn as_ref(&self) -> &[u8] {
303
+ /// &self.0
304
+ /// }
305
+ /// }
306
+ ///
302
307
/// impl AsMut<[u8]> for MyRngSeed {
303
308
/// fn as_mut(&mut self) -> &mut [u8] {
304
309
/// &mut self.0
@@ -313,7 +318,7 @@ pub trait SeedableRng: Sized {
313
318
/// }
314
319
/// }
315
320
/// ```
316
- type Seed : Sized + Default + AsMut < [ u8 ] > ;
321
+ type Seed : Clone + Default + AsRef < [ u8 ] > + AsMut < [ u8 ] > ;
317
322
318
323
/// Create a new PRNG using the given seed.
319
324
///
0 commit comments