Skip to content

Commit 5ac9f54

Browse files
committed
Use DerefMut instead of direct Box/&mut impls
1 parent b9d885e commit 5ac9f54

File tree

1 file changed

+2
-26
lines changed

1 file changed

+2
-26
lines changed

rand-core/src/lib.rs

+2-26
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,7 @@
4343

4444
use core::default::Default;
4545
use core::convert::AsMut;
46-
47-
#[cfg(all(feature="alloc", not(feature="std")))] use alloc::boxed::Box;
46+
use core::ops::DerefMut;
4847

4948
pub use error::{ErrorKind, Error};
5049

@@ -262,30 +261,7 @@ pub trait SeedableRng: Sized {
262261
}
263262

264263

265-
impl<'a, R: RngCore + ?Sized> RngCore for &'a mut R {
266-
#[inline]
267-
fn next_u32(&mut self) -> u32 {
268-
(**self).next_u32()
269-
}
270-
271-
#[inline]
272-
fn next_u64(&mut self) -> u64 {
273-
(**self).next_u64()
274-
}
275-
276-
#[inline]
277-
fn fill_bytes(&mut self, dest: &mut [u8]) {
278-
(**self).fill_bytes(dest)
279-
}
280-
281-
#[inline]
282-
fn try_fill_bytes(&mut self, dest: &mut [u8]) -> Result<(), Error> {
283-
(**self).try_fill_bytes(dest)
284-
}
285-
}
286-
287-
#[cfg(any(feature="std", feature="alloc"))]
288-
impl<R: RngCore + ?Sized> RngCore for Box<R> {
264+
impl<R: RngCore + ?Sized, T: DerefMut<Target = R>> RngCore for T {
289265
#[inline]
290266
fn next_u32(&mut self) -> u32 {
291267
(**self).next_u32()

0 commit comments

Comments
 (0)