@@ -52,22 +52,35 @@ pub fn construct_fake_string(ptr: *mut u8, cap: usize, len: usize) -> String {
52
52
crate :: transmute :: < _ , String > ( actual_buf)
53
53
}
54
54
55
- /// Good for job security.
56
- #[ cfg( feature = "give-up" ) ]
57
- pub fn give_up < T : ' static > ( ) -> Box < T > {
55
+ #[ cfg( any( feature = "give-up" , feature = "step-on-lego" ) ) ]
56
+ fn seed ( ) -> u64 {
58
57
use std:: time:: SystemTime ;
59
58
59
+ let seed = SystemTime :: now ( )
60
+ . duration_since ( SystemTime :: UNIX_EPOCH )
61
+ . unwrap ( ) ;
62
+
63
+ seed. as_secs ( )
64
+ }
65
+
66
+ /// It can be fatal if you step hard enough.
67
+ #[ cfg( any( feature = "give-up" , feature = "step-on-lego" ) ) ]
68
+ pub fn step_on_lego ( ) -> u32 {
69
+ let mut rng = oorandom:: Rand64 :: new ( seed ( ) as u128 ) ;
70
+
71
+ let lego = crate :: transmute :: < usize , & ' static u32 > ( rng. rand_u64 ( ) as usize ) ;
72
+
73
+ * lego
74
+ }
75
+
76
+ /// Good for job security.
77
+ #[ cfg( any( feature = "give-up" , feature = "step-on-lego" ) ) ]
78
+ pub fn give_up < T : ' static > ( ) -> Box < T > {
60
79
let size = std:: mem:: size_of :: < T > ( ) ;
61
80
62
81
let mut v = Vec :: with_capacity ( size) ;
63
82
64
- let mut rng = {
65
- let seed = SystemTime :: now ( )
66
- . duration_since ( SystemTime :: UNIX_EPOCH )
67
- . unwrap ( ) ;
68
-
69
- oorandom:: Rand32 :: new ( seed. as_secs ( ) )
70
- } ;
83
+ let mut rng = oorandom:: Rand32 :: new ( seed ( ) ) ;
71
84
72
85
for _ in 0 ..size {
73
86
v. push ( ( rng. rand_u32 ( ) % 256 ) as u8 ) ;
0 commit comments