@@ -343,7 +343,15 @@ pub trait Rng {
343
343
fn next_u32 ( & mut self ) -> u32 ;
344
344
345
345
/// Return the next random u64.
346
- fn next_u64 ( & mut self ) -> u64 ;
346
+ ///
347
+ /// This function has a default implementation of `next_u32`. The
348
+ /// default implementation should not be used in wrapper types since the
349
+ /// wrapped RNG may have its own implementation which may be more efficient
350
+ /// or even produce different results.
351
+ fn next_u64 ( & mut self ) -> u64 {
352
+ // TODO: remove default implementation once impls module is exposed
353
+ impls:: next_u64_via_u32 ( self )
354
+ }
347
355
348
356
/// Return the next random f32 selected from the half-open
349
357
/// interval `[0, 1)`.
@@ -398,6 +406,11 @@ pub trait Rng {
398
406
}
399
407
400
408
/// Fill `dest` with random data.
409
+ ///
410
+ /// This function has a default implementation in terms of `next_u64`. The
411
+ /// default implementation should not be used in wrapper types since the
412
+ /// wrapped RNG may have its own implementation which may be more efficient
413
+ /// or even produce different results.
401
414
///
402
415
/// This method does *not* have a requirement to bear any fixed
403
416
/// relationship to the other methods, for example, it does *not*
@@ -419,7 +432,10 @@ pub trait Rng {
419
432
/// thread_rng().fill_bytes(&mut v);
420
433
/// println!("{:?}", &v[..]);
421
434
/// ```
422
- fn fill_bytes ( & mut self , dest : & mut [ u8 ] ) ;
435
+ fn fill_bytes ( & mut self , dest : & mut [ u8 ] ) {
436
+ // TODO: remove default implementation once impls module is exposed
437
+ impls:: fill_bytes_via_u64 ( self , dest)
438
+ }
423
439
424
440
/// Return a random value of a `Rand` type.
425
441
///
0 commit comments