From 28aed81f7d3c03aebfe23832593be9a1cb610257 Mon Sep 17 00:00:00 2001 From: LingMan Date: Tue, 13 Apr 2021 18:42:19 +0200 Subject: [PATCH] Avoid an `Option>` By simply swapping the calls to `map` and `and_then` around the complexity of handling an `Option>` disappears. --- compiler/rustc_target/src/spec/mod.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/compiler/rustc_target/src/spec/mod.rs b/compiler/rustc_target/src/spec/mod.rs index 57b0a36e009..2af46693449 100644 --- a/compiler/rustc_target/src/spec/mod.rs +++ b/compiler/rustc_target/src/spec/mod.rs @@ -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)) };