Simplify some pattern-matches (#16402) (#16446)

When those match an exact combinator on Option / Result.

Tool-aided by [comby-rust](https://github.com/huitseeker/comby-rust).

(cherry picked from commit b08cff9e77)

Co-authored-by: François Garillot <4142+huitseeker@users.noreply.github.com>
This commit is contained in:
mergify[bot]
2021-04-08 20:45:01 +00:00
committed by GitHub
parent f7211d3c07
commit 723e7f11b9
18 changed files with 60 additions and 110 deletions

View File

@@ -1409,11 +1409,10 @@ pub mod tests {
// handle fanout^x -1, +0, +1 for a few 'x's
const FANOUT: usize = 3;
let mut hash_counts: Vec<_> = (1..6)
.map(|x| {
.flat_map(|x| {
let mark = FANOUT.pow(x);
vec![mark - 1, mark, mark + 1]
})
.flatten()
.collect();
// saturate the test space for threshold to threshold + target

View File

@@ -383,10 +383,11 @@ impl<'a> InvokeContext for ThisInvokeContext<'a> {
self.account_deps.iter().find(|(key, _)| key == pubkey)
{
Some(account.clone())
} else if let Some(pre) = self.pre_accounts.iter().find(|pre| pre.key == *pubkey) {
Some(pre.account.clone())
} else {
None
self.pre_accounts
.iter()
.find(|pre| pre.key == *pubkey)
.map(|pre| pre.account.clone())
}
} else {
if let Some(account) = self.pre_accounts.iter().find_map(|pre| {