Skip to content

Commit

Permalink
refactor: Redundant pattern matching, consider using is_ok()
Browse files Browse the repository at this point in the history
  • Loading branch information
bush1D3v committed Jul 31, 2024
1 parent 32809fd commit a521ce3
Showing 1 changed file with 4 additions and 10 deletions.
14 changes: 4 additions & 10 deletions src/modules/user/user_controllers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -106,10 +106,7 @@ async fn insert_user(
Ok(_) => (),
Err(e) => return HttpResponse::BadRequest().json(e),
};
let redis_user_conflict = match Redis::get(&redis_pool, &body.email.clone()).await {
Ok(_) => true,
Err(_) => false,
};
let redis_user_conflict = Redis::get(&redis_pool, &body.email.clone()).await.is_ok();
if redis_user_conflict {
HttpResponse::Conflict().json(error_construct(
String::from("email"),
Expand Down Expand Up @@ -764,10 +761,7 @@ async fn put_user(
Ok(_) => (),
Err(e) => return HttpResponse::BadRequest().json(e),
};
let redis_user_conflict = match Redis::get(&redis_pool, &body.new_email).await {
Ok(_) => true,
Err(_) => false,
};
let redis_user_conflict = Redis::get(&redis_pool, &body.new_email).await.is_ok();
if redis_user_conflict {
HttpResponse::Conflict().json(error_construct(
String::from("email"),
Expand Down Expand Up @@ -830,7 +824,7 @@ async fn put_user_response_constructor(
security(("bearer_auth" = [])),
responses((
status = 200, headers((
"access-control-allow-methods" = Vec<String>, description = "Métodos HTTP suportados pela entidade"
"access-control-allow-methods" = Vec<String>, description = "Métodos HTTP suportados nas rotas do seu prefixo"
)),
description = "Retorna quais métodos HTTP são suportados nas rotas do seu prefixo (OK)",
), (
Expand Down Expand Up @@ -864,7 +858,7 @@ async fn user_options(req: HttpRequest) -> impl Responder {
security(("bearer_auth" = [])),
responses((
status = 200, headers((
"access-control-allow-methods" = Vec<String>, description = "Métodos HTTP suportados pela entidade"
"access-control-allow-methods" = Vec<String>, description = "Métodos HTTP suportados nas rotas do seu prefixo"
)),
description = "Retorna quais métodos HTTP são suportados nas rotas do seu prefixo (OK)",
), (
Expand Down

0 comments on commit a521ce3

Please sign in to comment.