File tree Expand file tree Collapse file tree 2 files changed +12
-8
lines changed
Expand file tree Collapse file tree 2 files changed +12
-8
lines changed Original file line number Diff line number Diff line change 11[package ]
22name = " mt19937"
3- version = " 2 .0.1 "
3+ version = " 3 .0.0 "
44authors = [" Noa <coolreader18@gmail.com>" , " RustPython Team" ]
5- edition = " 2018 "
5+ edition = " 2021 "
66license-file = " LICENSE"
77description = " A translation of the MT19937 Mersenne Twister rng algorithm to Rust"
88documentation = " https://docs.rs/mt19937"
99repository = " https://github.com/RustPython/mt19937"
10+ rust-version = " 1.63"
1011
1112[dependencies ]
12- rand_core = " 0.6 "
13+ rand_core = " 0.9 "
Original file line number Diff line number Diff line change @@ -246,23 +246,26 @@ impl rand_core::RngCore for MT19937 {
246246 fn fill_bytes ( & mut self , dest : & mut [ u8 ] ) {
247247 rand_core:: impls:: fill_bytes_via_next ( self , dest)
248248 }
249- #[ inline]
250- fn try_fill_bytes ( & mut self , dest : & mut [ u8 ] ) -> Result < ( ) , rand_core:: Error > {
251- self . fill_bytes ( dest) ;
252- Ok ( ( ) )
253- }
254249}
255250
256251/// Seed for <MT19937 as rand_core::SeedableRng>
257252///
258253/// Very big seed, but this is the size that CPython uses as well
254+ #[ derive( Clone , Copy ) ]
259255pub struct Seed ( pub [ u32 ; N ] ) ;
260256impl Default for Seed {
261257 #[ inline]
262258 fn default ( ) -> Self {
263259 Seed ( [ 0 ; N ] )
264260 }
265261}
262+ impl AsRef < [ u8 ] > for Seed {
263+ #[ inline]
264+ fn as_ref ( & self ) -> & [ u8 ] {
265+ // this will always get the full bytes, since align_of(u32) > align_of(u8)
266+ unsafe { self . 0 . align_to ( ) . 1 }
267+ }
268+ }
266269impl AsMut < [ u8 ] > for Seed {
267270 #[ inline]
268271 fn as_mut ( & mut self ) -> & mut [ u8 ] {
You can’t perform that action at this time.
0 commit comments