Skip to content
This repository has been archived by the owner on Oct 19, 2024. It is now read-only.

Commit

Permalink
use simply expect
Browse files Browse the repository at this point in the history
  • Loading branch information
zsluedem committed Jan 15, 2023
1 parent 69c410a commit 108ca1a
Showing 1 changed file with 2 additions and 15 deletions.
17 changes: 2 additions & 15 deletions ethers-contract/ethers-contract-derive/src/abi_ty.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +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");
let name_str = name.to_string();
quote_spanned! { f.span() => #name: iter
.next()
.ok_or_else(|| #core_crate::abi::InvalidOutputType(::std::format!(
"Struct field {:} doesn't have correspond token.", #name_str
)))
.and_then(|t| #core_crate::abi::Tokenizable::from_token(t))?
}
quote_spanned! { f.span() => #name: #core_crate::abi::Tokenizable::from_token(iter.next().expect("No token found"))? }
});
let init_struct_impl = quote! { Self { #(#assignments,)* } };

Expand All @@ -66,13 +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() => iter
.next()
.ok_or_else(|| #core_crate::abi::InvalidOutputType(::std::format!(
"Struct unnamed field doesn't have correspond token."
)))
.and_then(|t| #core_crate::abi::Tokenizable::from_token(t))?
}
quote_spanned! { f.span() => #core_crate::abi::Tokenizable::from_token(iter.next().expect("No token found"))? }
});
let init_struct_impl = quote! { Self(#(#assignments,)* ) };

Expand Down

0 comments on commit 108ca1a

Please sign in to comment.