Move random utils to another trait.

This commit is contained in:
Bob McWhirter
2021-08-30 09:55:29 -04:00
parent 78f7d1b786
commit 7fa3b27cac
3 changed files with 8 additions and 4 deletions

View File

@ -5,9 +5,9 @@ pub trait Rng {
type Error;
#[rustfmt::skip]
type RngFuture<'a>: Future<Output = Result<(), Self::Error>> + 'a
type RngFuture<'a>: Future<Output = Result<(), Self::Error> > + 'a
where
Self: 'a;
Self: 'a;
/// Completely fill the provided buffer with random bytes.
///
@ -15,9 +15,11 @@ pub trait Rng {
/// filling the buffer. Upon completion, the buffer will be completely
/// filled or an error will have been reported.
fn fill_bytes<'a>(&'a mut self, dest: &'a mut [u8]) -> Self::RngFuture<'a>;
}
pub trait Random: Rng {
#[rustfmt::skip]
type NextFuture<'a>: Future<Output = Result<u32, Self::Error>> + 'a
type NextFuture<'a>: Future<Output = Result<u32, <Self as Rng>::Error>> + 'a
where
Self: 'a;