From 74102957f4d8e09c521e7c35e472a46deedebb0c Mon Sep 17 00:00:00 2001 From: Simon Warta Date: Mon, 28 Aug 2023 10:58:24 +0200 Subject: [PATCH] Use let-else --- libwasmvm/src/iterator.rs | 8 ++------ libwasmvm/src/storage.rs | 12 +++--------- 2 files changed, 5 insertions(+), 15 deletions(-) diff --git a/libwasmvm/src/iterator.rs b/libwasmvm/src/iterator.rs index d6098cbf7..93ce145b6 100644 --- a/libwasmvm/src/iterator.rs +++ b/libwasmvm/src/iterator.rs @@ -66,9 +66,7 @@ impl GoIter { } pub fn next(&mut self) -> BackendResult> { - let next = if let Some(f) = self.vtable.next { - f - } else { + let Some(next) = self.vtable.next else { let result = Err(BackendError::unknown( "iterator vtable function 'next' not set", )); @@ -139,9 +137,7 @@ impl GoIter { >, fn_name: &str, ) -> BackendResult>> { - let next = if let Some(f) = next_fn { - f - } else { + let Some(next) = next_fn else { let result = Err(BackendError::unknown(format!( "iterator vtable function '{fn_name}' not set" ))); diff --git a/libwasmvm/src/storage.rs b/libwasmvm/src/storage.rs index 22dbb7134..fc7a75046 100644 --- a/libwasmvm/src/storage.rs +++ b/libwasmvm/src/storage.rs @@ -104,9 +104,7 @@ impl Storage for GoStorage { } fn next(&mut self, iterator_id: u32) -> BackendResult> { - let iterator = if let Some(i) = self.iterators.get_mut(&iterator_id) { - i - } else { + let Some(iterator) = self.iterators.get_mut(&iterator_id) else { return ( Err(BackendError::iterator_does_not_exist(iterator_id)), GasInfo::free(), @@ -116,9 +114,7 @@ impl Storage for GoStorage { } fn next_key(&mut self, iterator_id: u32) -> BackendResult>> { - let iterator = if let Some(i) = self.iterators.get_mut(&iterator_id) { - i - } else { + let Some(iterator) = self.iterators.get_mut(&iterator_id) else { return ( Err(BackendError::iterator_does_not_exist(iterator_id)), GasInfo::free(), @@ -129,9 +125,7 @@ impl Storage for GoStorage { } fn next_value(&mut self, iterator_id: u32) -> BackendResult>> { - let iterator = if let Some(i) = self.iterators.get_mut(&iterator_id) { - i - } else { + let Some(iterator) = self.iterators.get_mut(&iterator_id) else { return ( Err(BackendError::iterator_does_not_exist(iterator_id)), GasInfo::free(),