git.delta.rocks / unique-network / refs/commits / d0e40b195e3e

difftreelog

fix PR suggestions

Trubnikov Sergey2022-12-02parent: #6539d35.patch.diff
in: master

1 file changed

modifiedcrates/evm-coder/procedural/src/abi_derive/derive_enum.rsdiffbeforeafterboth
13 #[cfg(feature = "stubgen")]13 #[cfg(feature = "stubgen")]
14 impl ::evm_coder::solidity::SolidityEnum for #name {14 impl ::evm_coder::solidity::SolidityEnum for #name {
15 fn solidity_option(&self) -> &str {15 fn solidity_option(&self) -> &str {
16 match Self::default() {16 match self {
17 #(#enum_options)*17 #(#enum_options)*
18 }18 }
19 }19 }
176 Ok(count)176 Ok(count)
177}177}
178178
179pub fn check_repr_u8(name: &syn::Ident, attrs: &Vec<syn::Attribute>) -> syn::Result<()> {179pub fn check_repr_u8(name: &syn::Ident, attrs: &Vec<syn::Attribute>) -> syn::Result<()> {
180 let mut has_repr = false;180 let mut has_repr = false;
181 for attr in attrs.iter() {181 for attr in attrs.iter() {
182 if attr.path.is_ident("repr") {
183 has_repr = true;
184 let meta = attr.parse_meta()?;
185 check_meta_u8(&meta)?;
186 }
187 }
188
189 if !has_repr {
190 return Err(syn::Error::new(name.span(), "Enum is not \"repr(u8)\""));
191 }
192
193 Ok(())
194}
195
182 if attr.path.is_ident("repr") {196fn check_meta_u8(meta: &syn::Meta) -> Result<(), syn::Error> {
183 has_repr = true;
184 match attr.parse_meta()? {197 match meta {
185 syn::Meta::List(p) => {198 syn::Meta::List(p) => {
186 for nm in p.nested.iter() {199 for nm in p.nested.iter() {
187 match nm {200 match nm {
206 }219 }
207 _ => {}220 _ => {}
208 };221 };
222 Ok(())
209 }223}
210 }
211
212 if !has_repr {
213 return Err(syn::Error::new(name.span(), "Enum is not \"repr(u8)\""));
214 }
215
216 Ok(())
217}
218224