Skip to content

Commit

Permalink
Avoid an Option<Option<_>>
Browse files Browse the repository at this point in the history
By simply swapping the calls to `map` and `and_then` around the complexity of
handling an `Option<Option<_>>` disappears.
  • Loading branch information
LingMan committed Apr 13, 2021
1 parent 2e7eb85 commit 28aed81
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions compiler/rustc_target/src/spec/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1446,8 +1446,8 @@ impl Target {

let get_req_field = |name: &str| {
obj.find(name)
.map(|s| s.as_string())
.and_then(|os| os.map(|s| s.to_string()))
.and_then(Json::as_string)
.map(str::to_string)
.ok_or_else(|| format!("Field {} in target specification is required", name))
};

Expand Down

0 comments on commit 28aed81

Please sign in to comment.