Skip to content

Commit

Permalink
Change unwraps to more idiomatic rust syntax
Browse files Browse the repository at this point in the history
  • Loading branch information
Miroito committed Mar 11, 2023
1 parent b143750 commit 47f7f42
Showing 1 changed file with 5 additions and 8 deletions.
13 changes: 5 additions & 8 deletions packages/perseus-rocket/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -134,14 +134,11 @@ where
.query_value::<bool>("was_incremental_match")
.and_then(|res| res.ok());

if entity_name_opt.is_none() || locale_opt.is_none() || was_incremental_match_opt.is_none() {
return Outcome::Failure(Status::BadRequest);
}

// All unwraps are guarded by the condition above
let entity_name = entity_name_opt.unwrap().to_string();
let locale = locale_opt.unwrap().to_string();
let was_incremental_match = was_incremental_match_opt.unwrap();
let (locale, entity_name, was_incremental_match) =
match (locale_opt, entity_name_opt, was_incremental_match_opt) {
(Some(l), Some(e), Some(w)) => (l.to_string(), e.to_string(), w),
_ => return Outcome::Failure(Status::BadRequest),
};

let raw_path = req.routed_segments(2..).collect::<Vec<&str>>().join("/");

Expand Down

0 comments on commit 47f7f42

Please sign in to comment.