mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-01 15:01:51 +00:00
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:
parent
2e7eb85b1d
commit
28aed81f7d
@ -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))
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user