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
1 changed files with 2 additions and 2 deletions
|
@ -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…
Add table
Add a link
Reference in a new issue