Add a convenience next(range) to Rng.

This commit is contained in:
Bob McWhirter
2021-08-27 16:10:01 -04:00
parent e56c6166dc
commit d525f51940
2 changed files with 28 additions and 0 deletions

View File

@ -4,6 +4,7 @@ use core::future::Future;
pub trait Rng {
type Error;
#[rustfmt::skip]
type RngFuture<'a>: Future<Output = Result<(), Self::Error>> + 'a
where
Self: 'a;
@ -14,4 +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>;
#[rustfmt::skip]
type NextFuture<'a>: Future<Output = Result<u32, Self::Error>> + 'a
where
Self: 'a;
fn next<'a>(&'a mut self, range: u32) -> Self::NextFuture<'a>;
}