Simplify some pattern-matches (#16402)
When those match an exact combinator on Option / Result. Tool-aided by [comby-rust](https://github.com/huitseeker/comby-rust).
This commit is contained in:
committed by
GitHub
parent
bb9d2fd07a
commit
b08cff9e77
@ -191,8 +191,7 @@ impl ClusterSlots {
|
||||
.read()
|
||||
.unwrap()
|
||||
.keys()
|
||||
.filter(|x| **x > root)
|
||||
.filter(|x| !my_slots.contains(*x))
|
||||
.filter(|x| **x > root && !my_slots.contains(*x))
|
||||
.map(|x| RepairType::HighestShred(*x, 0))
|
||||
.collect()
|
||||
}
|
||||
|
@ -747,8 +747,10 @@ mod test {
|
||||
let num_epoch_slots = crds
|
||||
.table
|
||||
.values()
|
||||
.filter(|value| value.insert_timestamp >= since)
|
||||
.filter(|value| matches!(value.value.data, CrdsData::EpochSlots(_, _)))
|
||||
.filter(|value| {
|
||||
value.insert_timestamp >= since
|
||||
&& matches!(value.value.data, CrdsData::EpochSlots(_, _))
|
||||
})
|
||||
.count();
|
||||
assert_eq!(num_epoch_slots, crds.get_epoch_slots_since(since).count());
|
||||
for value in crds.get_epoch_slots_since(since) {
|
||||
|
@ -226,10 +226,7 @@ pub fn into_shreds(
|
||||
chunk_index,
|
||||
chunk,
|
||||
..
|
||||
} = match chunks.next() {
|
||||
None => return Err(Error::InvalidDuplicateShreds),
|
||||
Some(chunk) => chunk,
|
||||
};
|
||||
} = chunks.next().ok_or(Error::InvalidDuplicateShreds)?;
|
||||
let slot_leader = leader(slot).ok_or(Error::UnknownSlotLeader)?;
|
||||
let check_chunk = check_chunk(slot, shred_index, shred_type, num_chunks);
|
||||
let mut data = HashMap::new();
|
||||
|
@ -3185,16 +3185,14 @@ pub mod rpc_full {
|
||||
let address = verify_pubkey(address)?;
|
||||
|
||||
let config = config.unwrap_or_default();
|
||||
let before = if let Some(before) = config.before {
|
||||
Some(verify_signature(&before)?)
|
||||
} else {
|
||||
None
|
||||
};
|
||||
let until = if let Some(until) = config.until {
|
||||
Some(verify_signature(&until)?)
|
||||
} else {
|
||||
None
|
||||
};
|
||||
let before = config
|
||||
.before
|
||||
.map(|ref before| verify_signature(before))
|
||||
.transpose()?;
|
||||
let until = config
|
||||
.until
|
||||
.map(|ref until| verify_signature(until))
|
||||
.transpose()?;
|
||||
let limit = config
|
||||
.limit
|
||||
.unwrap_or(MAX_GET_CONFIRMED_SIGNATURES_FOR_ADDRESS2_LIMIT);
|
||||
|
Reference in New Issue
Block a user