Auto merge of #84164 - LingMan:option_option, r=estebank

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
This commit is contained in:
bors 2021-04-13 18:04:20 +00:00
commit 132b4e5d16

View File

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