mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-27 08:07:58 +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
@@ -77,10 +77,8 @@ impl<T: FullCodec, G: StorageValue<T>> storage::StorageValue<T> for G {
|
||||
let key = Self::storage_value_final_key();
|
||||
|
||||
// attempt to get the length directly.
|
||||
let maybe_old = match unhashed::get_raw(&key) {
|
||||
Some(old_data) => Some(O::decode(&mut &old_data[..]).map_err(|_| ())?),
|
||||
None => None,
|
||||
};
|
||||
let maybe_old = unhashed::get_raw(&key)
|
||||
.map(|old_data| O::decode(&mut &old_data[..]).map_err(|_| ())).transpose()?;
|
||||
let maybe_new = f(maybe_old);
|
||||
if let Some(new) = maybe_new.as_ref() {
|
||||
new.using_encoded(|d| unhashed::put_raw(&key, d));
|
||||
|
||||
Reference in New Issue
Block a user