mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-14 12:11:09 +00:00
Simplify some Option / Result / ? operator patterns (#8653)
* Simplify some Option / Result / ? operator patterns When those match a combinator exactly. Tool-aided by [comby-rust](https://github.com/huitseeker/comby-rust). * adjust after review * adjust post-review
This commit is contained in:
committed by
GitHub
parent
541692c4a8
commit
052be8bbef
@@ -195,7 +195,7 @@ pub fn extract_all_signature_types(items: &[ImplItem]) -> Vec<Type> {
|
||||
ImplItem::Method(method) => Some(&method.sig),
|
||||
_ => None,
|
||||
})
|
||||
.map(|sig| {
|
||||
.flat_map(|sig| {
|
||||
let ret_ty = match &sig.output {
|
||||
ReturnType::Default => None,
|
||||
ReturnType::Type(_, ty) => Some((**ty).clone()),
|
||||
@@ -209,7 +209,6 @@ pub fn extract_all_signature_types(items: &[ImplItem]) -> Vec<Type> {
|
||||
_ => (**ty).clone(),
|
||||
}).chain(ret_ty)
|
||||
})
|
||||
.flatten()
|
||||
.collect()
|
||||
}
|
||||
|
||||
|
||||
@@ -237,13 +237,10 @@ impl<Block: BlockT, Transaction> BlockImportParams<Block, Transaction> {
|
||||
pub fn take_intermediate<T: 'static>(&mut self, key: &[u8]) -> Result<Box<T>, Error> {
|
||||
let (k, v) = self.intermediates.remove_entry(key).ok_or(Error::NoIntermediate)?;
|
||||
|
||||
match v.downcast::<T>() {
|
||||
Ok(v) => Ok(v),
|
||||
Err(v) => {
|
||||
v.downcast::<T>().or_else(|v| {
|
||||
self.intermediates.insert(k, v);
|
||||
Err(Error::InvalidIntermediate)
|
||||
},
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
/// Get a reference to a given intermediate.
|
||||
|
||||
Reference in New Issue
Block a user