From c60990d7b6e6b3034f1e50b27b495aeda30e35e8 Mon Sep 17 00:00:00 2001 From: WillQ Date: Wed, 18 Jan 2023 03:15:59 +0800 Subject: [PATCH] remove EthAbiType derive generated unwrap (#2056) * remove EthAbiType derive generated unwrap * use simply expect --- ethers-contract/ethers-contract-derive/src/abi_ty.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ethers-contract/ethers-contract-derive/src/abi_ty.rs b/ethers-contract/ethers-contract-derive/src/abi_ty.rs index 442d9d1d..b6e6dfda 100644 --- a/ethers-contract/ethers-contract-derive/src/abi_ty.rs +++ b/ethers-contract/ethers-contract-derive/src/abi_ty.rs @@ -39,7 +39,7 @@ pub fn derive_tokenizeable_impl(input: &DeriveInput) -> proc_macro2::TokenStream let assignments = fields.named.iter().map(|f| { let name = f.ident.as_ref().expect("Named fields have names"); - quote_spanned! { f.span() => #name: #core_crate::abi::Tokenizable::from_token(iter.next().unwrap())? } + quote_spanned! { f.span() => #name: #core_crate::abi::Tokenizable::from_token(iter.next().expect("The iter is guaranteed to be something due to the size check"))? } }); let init_struct_impl = quote! { Self { #(#assignments,)* } }; @@ -59,7 +59,7 @@ pub fn derive_tokenizeable_impl(input: &DeriveInput) -> proc_macro2::TokenStream let tokenize_predicates = quote! { #(#tokenize_predicates,)* }; let assignments = fields.unnamed.iter().map(|f| { - quote_spanned! { f.span() => #core_crate::abi::Tokenizable::from_token(iter.next().unwrap())? } + quote_spanned! { f.span() => #core_crate::abi::Tokenizable::from_token(iter.next().expect("The iter is guaranteed to be something due to the size check"))? } }); let init_struct_impl = quote! { Self(#(#assignments,)* ) };