Avoid an Option<Option<_>>

By simply swapping the calls to `map` and `and_then` around the complexity of
handling an `Option<Option<_>>` disappears.
This commit is contained in:
LingMan 2021-04-13 18:42:19 +02:00
parent 2e7eb85b1d
commit 28aed81f7d

View File

@ -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))
};