Skip to content

Commit

Permalink
Remove unsafe code from examples (#585)
Browse files Browse the repository at this point in the history
* Remove unsafe code from examples

* cargo clippy
  • Loading branch information
astoring authored Dec 28, 2023
1 parent cc7c172 commit 5b6179f
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion examples/db-mongodb/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ static MONGODB_CLIENT: OnceCell<Client> = OnceCell::new();

#[inline]
pub fn get_mongodb_client() -> &'static Client {
unsafe { MONGODB_CLIENT.get_unchecked() }
MONGODB_CLIENT.get().unwrap()
}

#[handler]
Expand Down
2 changes: 1 addition & 1 deletion examples/db-mysql-rbatis/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ impl_select!(User{select_by_id(id:String) -> Option => "`where id = #{id} limit
#[handler]
pub async fn get_user(req: &mut Request, res: &mut Response) {
let uid = req.query::<i64>("uid").unwrap();
let data = User::select_by_id(&mut RB.clone(), uid.to_string()).await.unwrap();
let data = User::select_by_id(&*RB, uid.to_string()).await.unwrap();
println!("{data:?}");
res.render(serde_json::to_string(&data).unwrap());
}
Expand Down
2 changes: 1 addition & 1 deletion examples/db-postgres-sqlx/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ static POSTGRES: OnceCell<PgPool> = OnceCell::new();

#[inline]
pub fn get_postgres() -> &'static PgPool {
unsafe { POSTGRES.get_unchecked() }
POSTGRES.get().unwrap()
}

#[derive(FromRow, Serialize, Debug)]
Expand Down

0 comments on commit 5b6179f

Please sign in to comment.