Skip to content

Commit 9abb258

Browse files
committed
Fix clippy warnings
1 parent a762bf8 commit 9abb258

File tree

2 files changed

+7
-6
lines changed

2 files changed

+7
-6
lines changed

vm/src/stdlib/random.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ mod mersenne;
1717
#[derive(Debug)]
1818
enum PyRng {
1919
Std(rand::rngs::ThreadRng),
20-
MT(mersenne::MT19937),
20+
MT(Box<mersenne::MT19937>),
2121
}
2222

2323
impl Default for PyRng {
@@ -89,7 +89,7 @@ impl PyRandom {
8989
if cfg!(target_endian = "big") {
9090
key.reverse();
9191
}
92-
PyRng::MT(mersenne::MT19937::new_with_slice_seed(&key))
92+
PyRng::MT(Box::new(mersenne::MT19937::new_with_slice_seed(&key)))
9393
}
9494
};
9595

vm/src/stdlib/random/mersenne.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#![allow(clippy::unreadable_literal)]
2+
13
/*
24
A C-program for MT19937, with initialization improved 2002/1/26.
35
Coded by Takuji Nishimura and Makoto Matsumoto.
@@ -78,7 +80,7 @@ impl MT19937 {
7880

7981
/* initializes self.mt[N] with a seed */
8082
fn seed(&mut self, s: u32) {
81-
self.mt[0] = s & 0xffffffffu32;
83+
self.mt[0] = s;
8284
self.mti = 1;
8385
while self.mti < N {
8486
self.mt[self.mti] = 1812433253u32
@@ -88,8 +90,6 @@ impl MT19937 {
8890
/* In the previous versions, MSBs of the seed affect */
8991
/* only MSBs of the array self.mt[]. */
9092
/* 2002/01/09 modified by Makoto Matsumoto */
91-
self.mt[self.mti] &= 0xffffffffu32;
92-
/* for >32 bit machines */
9393
self.mti += 1;
9494
}
9595
}
@@ -205,6 +205,7 @@ impl rand::RngCore for MT19937 {
205205
rand_core::impls::fill_bytes_via_next(self, dest)
206206
}
207207
fn try_fill_bytes(&mut self, dest: &mut [u8]) -> Result<(), rand::Error> {
208-
Ok(self.fill_bytes(dest))
208+
self.fill_bytes(dest);
209+
Ok(())
209210
}
210211
}

0 commit comments

Comments
 (0)