@@ -19,9 +19,9 @@ use std::fmt::Display;
1919use std:: fmt:: Formatter ;
2020use std:: mem:: discriminant;
2121
22- use rand:: distributions :: Alphanumeric ;
23- use rand:: distributions :: DistString ;
24- use rand:: thread_rng ;
22+ use rand:: distr :: Alphanumeric ;
23+ use rand:: distr :: SampleString ;
24+ use rand:: rng ;
2525use rand:: Rng ;
2626
2727use super :: number:: Number ;
@@ -269,18 +269,18 @@ impl<'a> Value<'a> {
269269
270270 /// generate random JSONB value
271271 pub fn rand_value ( ) -> Value < ' static > {
272- let mut rng = thread_rng ( ) ;
273- let val = match rng. gen_range ( 0 ..=2 ) {
272+ let mut rng = rng ( ) ;
273+ let val = match rng. random_range ( 0 ..=2 ) {
274274 0 => {
275- let len = rng. gen_range ( 0 ..=5 ) ;
275+ let len = rng. random_range ( 0 ..=5 ) ;
276276 let mut values = Vec :: with_capacity ( len) ;
277277 for _ in 0 ..len {
278278 values. push ( Self :: rand_scalar_value ( ) ) ;
279279 }
280280 Value :: Array ( values)
281281 }
282282 1 => {
283- let len = rng. gen_range ( 0 ..=5 ) ;
283+ let len = rng. random_range ( 0 ..=5 ) ;
284284 let mut obj = Object :: new ( ) ;
285285 for _ in 0 ..len {
286286 let k = Alphanumeric . sample_string ( & mut rng, 5 ) ;
@@ -295,27 +295,27 @@ impl<'a> Value<'a> {
295295 }
296296
297297 fn rand_scalar_value ( ) -> Value < ' static > {
298- let mut rng = thread_rng ( ) ;
299- let val = match rng. gen_range ( 0 ..=3 ) {
298+ let mut rng = rng ( ) ;
299+ let val = match rng. random_range ( 0 ..=3 ) {
300300 0 => {
301- let v = rng. gen_bool ( 0.5 ) ;
301+ let v = rng. random_bool ( 0.5 ) ;
302302 Value :: Bool ( v)
303303 }
304304 1 => {
305305 let s = Alphanumeric . sample_string ( & mut rng, 5 ) ;
306306 Value :: String ( Cow :: from ( s) )
307307 }
308- 2 => match rng. gen_range ( 0 ..=2 ) {
308+ 2 => match rng. random_range ( 0 ..=2 ) {
309309 0 => {
310- let n: u64 = rng. gen_range ( 0 ..=100000 ) ;
310+ let n: u64 = rng. random_range ( 0 ..=100000 ) ;
311311 Value :: Number ( Number :: UInt64 ( n) )
312312 }
313313 1 => {
314- let n: i64 = rng. gen_range ( -100000 ..=100000 ) ;
314+ let n: i64 = rng. random_range ( -100000 ..=100000 ) ;
315315 Value :: Number ( Number :: Int64 ( n) )
316316 }
317317 _ => {
318- let n: f64 = rng. gen_range ( -4000.0 ..1.3e5 ) ;
318+ let n: f64 = rng. random_range ( -4000.0 ..1.3e5 ) ;
319319 Value :: Number ( Number :: Float64 ( n) )
320320 }
321321 } ,
0 commit comments