File tree Expand file tree Collapse file tree 2 files changed +15
-9
lines changed Expand file tree Collapse file tree 2 files changed +15
-9
lines changed Original file line number Diff line number Diff line change 6
6
// option. This file may not be copied, modified, or distributed
7
7
// except according to those terms.
8
8
9
- use byteorder:: { ByteOrder , LittleEndian } ;
10
9
use rand_core;
11
10
use rand_core:: le:: read_u32_into;
12
11
use rand_core:: impls:: { fill_bytes_via_next, next_u64_via_u32} ;
@@ -71,9 +70,7 @@ impl SeedableRng for Xoroshiro64Star {
71
70
72
71
/// Seed a `Xoroshiro64Star` from a `u64` using `SplitMix64`.
73
72
fn seed_from_u64 ( seed : u64 ) -> Xoroshiro64Star {
74
- let mut s = [ 0 ; 8 ] ;
75
- LittleEndian :: write_u64 ( & mut s, seed) ;
76
- Xoroshiro64Star :: from_seed ( s)
73
+ from_splitmix ! ( seed)
77
74
}
78
75
}
79
76
@@ -94,4 +91,10 @@ mod tests {
94
91
assert_eq ! ( rng. next_u32( ) , e) ;
95
92
}
96
93
}
94
+
95
+ #[ test]
96
+ fn zero_seed ( ) {
97
+ let mut rng = Xoroshiro64Star :: seed_from_u64 ( 0 ) ;
98
+ assert_ne ! ( rng. next_u64( ) , 0 ) ;
99
+ }
97
100
}
Original file line number Diff line number Diff line change 6
6
// option. This file may not be copied, modified, or distributed
7
7
// except according to those terms.
8
8
9
- use byteorder:: { ByteOrder , LittleEndian } ;
10
9
use rand_core;
11
10
use rand_core:: le:: read_u32_into;
12
11
use rand_core:: impls:: { fill_bytes_via_next, next_u64_via_u32} ;
@@ -68,11 +67,9 @@ impl SeedableRng for Xoroshiro64StarStar {
68
67
}
69
68
}
70
69
71
- /// Seed a `Xoroshiro64StarStar` from a `u64`.
70
+ /// Seed a `Xoroshiro64StarStar` from a `u64` using `SplitMix64` .
72
71
fn seed_from_u64 ( seed : u64 ) -> Xoroshiro64StarStar {
73
- let mut s = [ 0 ; 8 ] ;
74
- LittleEndian :: write_u64 ( & mut s, seed) ;
75
- Xoroshiro64StarStar :: from_seed ( s)
72
+ from_splitmix ! ( seed)
76
73
}
77
74
}
78
75
@@ -93,4 +90,10 @@ mod tests {
93
90
assert_eq ! ( rng. next_u32( ) , e) ;
94
91
}
95
92
}
93
+
94
+ #[ test]
95
+ fn zero_seed ( ) {
96
+ let mut rng = Xoroshiro64StarStar :: seed_from_u64 ( 0 ) ;
97
+ assert_ne ! ( rng. next_u64( ) , 0 ) ;
98
+ }
96
99
}
You can’t perform that action at this time.
0 commit comments