Skip to content

Commit 7959fbf

Browse files
committed
Implement std::io::Read for RngCore
1 parent 335c390 commit 7959fbf

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

rand_core/src/lib.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -439,3 +439,11 @@ impl<R: RngCore + ?Sized> RngCore for Box<R> {
439439
(**self).try_fill_bytes(dest)
440440
}
441441
}
442+
443+
#[cfg(feature="std")]
444+
impl std::io::Read for RngCore {
445+
fn read(&mut self, buf: &mut [u8]) -> Result<usize, std::io::Error> {
446+
self.try_fill_bytes(buf)?;
447+
Ok(buf.len())
448+
}
449+
}

0 commit comments

Comments
 (0)