@@ -14,7 +14,7 @@ use core::num::Wrapping as w;
14
14
use core:: { fmt, slice} ;
15
15
use rand_core:: block:: { BlockRng64 , BlockRngCore } ;
16
16
use rand_core:: { le, RngCore , SeedableRng , TryRngCore } ;
17
- #[ cfg( feature = "serde1 " ) ]
17
+ #[ cfg( feature = "serde " ) ]
18
18
use serde:: { Deserialize , Serialize } ;
19
19
20
20
#[ allow( non_camel_case_types) ]
@@ -81,7 +81,7 @@ const RAND_SIZE: usize = 1 << RAND_SIZE_LEN;
81
81
/// [`rand_hc`]: https://docs.rs/rand_hc
82
82
/// [`BlockRng64`]: rand_core::block::BlockRng64
83
83
#[ derive( Debug , Clone ) ]
84
- #[ cfg_attr( feature = "serde1 " , derive( Serialize , Deserialize ) ) ]
84
+ #[ cfg_attr( feature = "serde " , derive( Serialize , Deserialize ) ) ]
85
85
pub struct Isaac64Rng ( BlockRng64 < Isaac64Core > ) ;
86
86
87
87
impl RngCore for Isaac64Rng {
@@ -101,8 +101,6 @@ impl RngCore for Isaac64Rng {
101
101
}
102
102
}
103
103
104
- rand_core:: impl_try_rng_from_rng_core!( Isaac64Rng ) ;
105
-
106
104
impl SeedableRng for Isaac64Rng {
107
105
type Seed = <Isaac64Core as SeedableRng >:: Seed ;
108
106
@@ -120,22 +118,22 @@ impl SeedableRng for Isaac64Rng {
120
118
}
121
119
122
120
#[ inline]
123
- fn from_rng ( rng : impl RngCore ) -> Self {
121
+ fn from_rng ( rng : & mut impl RngCore ) -> Self {
124
122
Isaac64Rng ( BlockRng64 :: < Isaac64Core > :: from_rng ( rng) )
125
123
}
126
124
127
125
#[ inline]
128
- fn try_from_rng < S : TryRngCore > ( rng : S ) -> Result < Self , S :: Error > {
126
+ fn try_from_rng < S : TryRngCore > ( rng : & mut S ) -> Result < Self , S :: Error > {
129
127
BlockRng64 :: < Isaac64Core > :: try_from_rng ( rng) . map ( Isaac64Rng )
130
128
}
131
129
}
132
130
133
131
/// The core of `Isaac64Rng`, used with `BlockRng`.
134
132
#[ derive( Clone ) ]
135
- #[ cfg_attr( feature = "serde1 " , derive( Serialize , Deserialize ) ) ]
133
+ #[ cfg_attr( feature = "serde " , derive( Serialize , Deserialize ) ) ]
136
134
pub struct Isaac64Core {
137
135
#[ cfg_attr(
138
- feature = "serde1 " ,
136
+ feature = "serde " ,
139
137
serde( with = "super::isaac_array::isaac_array_serde" )
140
138
) ]
141
139
mem : [ w64 ; RAND_SIZE ] ,
@@ -329,7 +327,7 @@ impl SeedableRng for Isaac64Core {
329
327
Self :: init ( key, 1 )
330
328
}
331
329
332
- fn from_rng ( mut rng : impl RngCore ) -> Self {
330
+ fn from_rng ( rng : & mut impl RngCore ) -> Self {
333
331
// Custom `from_rng` implementation that fills a seed with the same size
334
332
// as the entire state.
335
333
let mut seed = [ w ( 0u64 ) ; RAND_SIZE ] ;
@@ -345,7 +343,7 @@ impl SeedableRng for Isaac64Core {
345
343
Self :: init ( seed, 2 )
346
344
}
347
345
348
- fn try_from_rng < R : TryRngCore > ( mut rng : R ) -> Result < Self , R :: Error > {
346
+ fn try_from_rng < R : TryRngCore > ( rng : & mut R ) -> Result < Self , R :: Error > {
349
347
// Custom `from_rng` implementation that fills a seed with the same size
350
348
// as the entire state.
351
349
let mut seed = [ w ( 0u64 ) ; RAND_SIZE ] ;
@@ -377,7 +375,7 @@ mod test {
377
375
let mut rng1 = Isaac64Rng :: from_seed ( seed) ;
378
376
assert_eq ! ( rng1. next_u64( ) , 14964555543728284049 ) ;
379
377
380
- let mut rng2 = Isaac64Rng :: from_rng ( rng1) ;
378
+ let mut rng2 = Isaac64Rng :: from_rng ( & mut rng1) ;
381
379
assert_eq ! ( rng2. next_u64( ) , 919595328260451758 ) ;
382
380
}
383
381
@@ -538,7 +536,7 @@ mod test {
538
536
}
539
537
540
538
#[ test]
541
- #[ cfg( feature = "serde1 " ) ]
539
+ #[ cfg( feature = "serde " ) ]
542
540
fn test_isaac64_serde ( ) {
543
541
use bincode;
544
542
use std:: io:: { BufReader , BufWriter } ;
0 commit comments