11use std:: { collections:: HashMap , fmt:: Write , io, sync:: Arc } ;
22
33use futures_util:: { stream:: FuturesUnordered , StreamExt , TryFutureExt , TryStreamExt } ;
4- use rand:: { rngs:: SmallRng , thread_rng , Rng , SeedableRng } ;
4+ use rand:: { rng , rngs:: SmallRng , Rng , SeedableRng } ;
55use tokio:: pin;
66use tokio_postgres:: { connect, types:: ToSql , Client , NoTls , Statement } ;
77use viz:: { Error , IntoResponse , Response , StatusCode } ;
@@ -105,14 +105,14 @@ impl PgConnection {
105105 }
106106
107107 pub async fn get_world ( & self ) -> Result < World , PgError > {
108- let mut rng = SmallRng :: from_rng ( & mut thread_rng ( ) ) . unwrap ( ) ;
108+ let mut rng = SmallRng :: from_rng ( & mut rng ( ) ) ;
109109 let random_id = ( rng. gen :: < u32 > ( ) % 10_000 + 1 ) as i32 ;
110110
111111 self . query_one_world ( random_id) . await
112112 }
113113
114114 pub async fn get_worlds ( & self , num : u16 ) -> Result < Vec < World > , PgError > {
115- let mut rng = SmallRng :: from_rng ( & mut thread_rng ( ) ) . unwrap ( ) ;
115+ let mut rng = SmallRng :: from_rng ( & mut rng ( ) ) ;
116116
117117 let worlds = FuturesUnordered :: new ( ) ;
118118
@@ -125,7 +125,7 @@ impl PgConnection {
125125 }
126126
127127 pub async fn update ( & self , num : u16 ) -> Result < Vec < World > , PgError > {
128- let mut rng = SmallRng :: from_rng ( & mut thread_rng ( ) ) . unwrap ( ) ;
128+ let mut rng = SmallRng :: from_rng ( & mut rng ( ) ) ;
129129
130130 let worlds = FuturesUnordered :: new ( ) ;
131131
0 commit comments