Skip to content

Commit 2f07817

Browse files
committed
Tidy up dynamic dispatch code
1 parent 5e28ec9 commit 2f07817

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

src/lib.rs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -637,7 +637,7 @@ pub trait Rng {
637637
}
638638
}
639639

640-
impl<'a, R: ?Sized> Rng for &'a mut R where R: Rng {
640+
impl<'a, R: Rng + ?Sized> Rng for &'a mut R {
641641
#[inline]
642642
fn next_u32(&mut self) -> u32 {
643643
(**self).next_u32()
@@ -670,7 +670,7 @@ impl<'a, R: ?Sized> Rng for &'a mut R where R: Rng {
670670
}
671671

672672
#[cfg(any(feature="std", feature="alloc"))]
673-
impl<R: ?Sized> Rng for Box<R> where R: Rng {
673+
impl<R: Rng + ?Sized> Rng for Box<R> {
674674
#[inline]
675675
fn next_u32(&mut self) -> u32 {
676676
(**self).next_u32()
@@ -1389,12 +1389,13 @@ mod test {
13891389
{
13901390
let mut r = &mut rng as &mut Rng;
13911391
r.next_u32();
1392-
(&mut r).gen::<i32>();
1392+
let r2 = &mut r;
1393+
r2.gen::<i32>();
13931394
let mut v = [1, 1, 1];
1394-
(&mut r).shuffle(&mut v);
1395+
r2.shuffle(&mut v);
13951396
let b: &[_] = &[1, 1, 1];
13961397
assert_eq!(v, b);
1397-
assert_eq!((&mut r).gen_range(0, 1), 0);
1398+
assert_eq!(r2.gen_range(0, 1), 0);
13981399
}
13991400
{
14001401
let mut r = Box::new(rng) as Box<Rng>;

0 commit comments

Comments
 (0)