From 73792f8caa6cdf4a168f6bf08fbde92fda09a576 Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Thu, 28 Sep 2023 00:12:37 +0200 Subject: [PATCH] chore: simpler ENCODED_SIZE for SolType tuples --- crates/sol-types/src/types/data_type.rs | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/crates/sol-types/src/types/data_type.rs b/crates/sol-types/src/types/data_type.rs index 5989c8bfc1..c11f404574 100644 --- a/crates/sol-types/src/types/data_type.rs +++ b/crates/sol-types/src/types/data_type.rs @@ -598,16 +598,15 @@ macro_rules! tuple_impls { type RustType = ($( $ty::RustType, )+); type TokenType<'a> = ($( $ty::TokenType<'a>, )+); - const ENCODED_SIZE: Option = { - let mut acc = Some(0); + const ENCODED_SIZE: Option = 'l: { + let mut acc = 0; $( - match (acc, <$ty as SolType>::ENCODED_SIZE) { - (Some(i), Some(size)) => acc = Some(i + size), - (Some(_), None) => acc = None, - (None, _) => {} + match <$ty as SolType>::ENCODED_SIZE { + Some(size) => acc += size, + None => break 'l None, } )+ - acc + Some(acc) }; fn sol_type_name() -> Cow<'static, str> {