Skip to content

Commit

Permalink
Auto merge of #84164 - LingMan:option_option, r=estebank
Browse files Browse the repository at this point in the history
Avoid an `Option<Option<_>>`

By simply swapping the calls to `map` and `and_then` around the complexity of
handling an `Option<Option<_>>` disappears.

`@rustbot` modify labels +C-cleanup +T-compiler
  • Loading branch information
bors committed Apr 13, 2021
2 parents 5c13042 + 28aed81 commit 132b4e5
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 132b4e5

Please sign in to comment.