From 5ac9f5499e3f3a13b751fc8696648b4e5a7610d8 Mon Sep 17 00:00:00 2001 From: Diggory Hardy Date: Fri, 9 Mar 2018 10:21:46 +0000 Subject: [PATCH] Use DerefMut instead of direct Box/&mut impls --- rand-core/src/lib.rs | 28 ++-------------------------- 1 file changed, 2 insertions(+), 26 deletions(-) diff --git a/rand-core/src/lib.rs b/rand-core/src/lib.rs index c29a00573fd..15ff848f040 100644 --- a/rand-core/src/lib.rs +++ b/rand-core/src/lib.rs @@ -43,8 +43,7 @@ use core::default::Default; use core::convert::AsMut; - -#[cfg(all(feature="alloc", not(feature="std")))] use alloc::boxed::Box; +use core::ops::DerefMut; pub use error::{ErrorKind, Error}; @@ -262,30 +261,7 @@ pub trait SeedableRng: Sized { } -impl<'a, R: RngCore + ?Sized> RngCore for &'a mut R { - #[inline] - fn next_u32(&mut self) -> u32 { - (**self).next_u32() - } - - #[inline] - fn next_u64(&mut self) -> u64 { - (**self).next_u64() - } - - #[inline] - fn fill_bytes(&mut self, dest: &mut [u8]) { - (**self).fill_bytes(dest) - } - - #[inline] - fn try_fill_bytes(&mut self, dest: &mut [u8]) -> Result<(), Error> { - (**self).try_fill_bytes(dest) - } -} - -#[cfg(any(feature="std", feature="alloc"))] -impl RngCore for Box { +impl> RngCore for T { #[inline] fn next_u32(&mut self) -> u32 { (**self).next_u32()