Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 7 additions & 9 deletions src/unwrap_err.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,26 +34,24 @@ impl<R: TryRng> TryRng for UnwrapErr<R> {

#[inline]
fn try_next_u32(&mut self) -> Result<u32, Self::Error> {
self.0
.try_next_u32()
.map_err(|err| panic!("rand_core::UnwrapErr: failed to unwrap: {err}"))
self.0.try_next_u32().map_err(panic_msg)
}

#[inline]
fn try_next_u64(&mut self) -> Result<u64, Self::Error> {
self.0
.try_next_u64()
.map_err(|err| panic!("rand_core::UnwrapErr: failed to unwrap: {err}"))
self.0.try_next_u64().map_err(panic_msg)
}

#[inline]
fn try_fill_bytes(&mut self, dst: &mut [u8]) -> Result<(), Self::Error> {
self.0
.try_fill_bytes(dst)
.map_err(|err| panic!("rand_core::UnwrapErr: failed to unwrap: {err}"))
self.0.try_fill_bytes(dst).map_err(panic_msg)
}
}

fn panic_msg(err: impl core::error::Error) -> Infallible {
panic!("rand_core::UnwrapErr: failed to unwrap: {err}")
}

impl<R: TryCryptoRng> TryCryptoRng for UnwrapErr<R> {}

impl<'r, R: TryRng + ?Sized> UnwrapErr<&'r mut R> {
Expand Down