|
@@ -203,7 +203,7 @@ fn parse_program_mod(ctx: &CrateContext) -> Option<syn::ItemMod> {
|
|
|
|
|
|
fn parse_error_enum(ctx: &CrateContext) -> Option<syn::ItemEnum> {
|
|
fn parse_error_enum(ctx: &CrateContext) -> Option<syn::ItemEnum> {
|
|
ctx.enums()
|
|
ctx.enums()
|
|
- .filter_map(|item_enum| {
|
|
|
|
|
|
+ .find(|item_enum| {
|
|
let attrs_count = item_enum
|
|
let attrs_count = item_enum
|
|
.attrs
|
|
.attrs
|
|
.iter()
|
|
.iter()
|
|
@@ -213,18 +213,17 @@ fn parse_error_enum(ctx: &CrateContext) -> Option<syn::ItemEnum> {
|
|
})
|
|
})
|
|
.count();
|
|
.count();
|
|
match attrs_count {
|
|
match attrs_count {
|
|
- 0 => None,
|
|
|
|
- 1 => Some(item_enum),
|
|
|
|
|
|
+ 0 => false,
|
|
|
|
+ 1 => true,
|
|
_ => panic!("Invalid syntax: one error attribute allowed"),
|
|
_ => panic!("Invalid syntax: one error attribute allowed"),
|
|
}
|
|
}
|
|
})
|
|
})
|
|
- .next()
|
|
|
|
.cloned()
|
|
.cloned()
|
|
}
|
|
}
|
|
|
|
|
|
fn parse_events(ctx: &CrateContext) -> Vec<&syn::ItemStruct> {
|
|
fn parse_events(ctx: &CrateContext) -> Vec<&syn::ItemStruct> {
|
|
ctx.structs()
|
|
ctx.structs()
|
|
- .filter_map(|item_strct| {
|
|
|
|
|
|
+ .filter(|item_strct| {
|
|
let attrs_count = item_strct
|
|
let attrs_count = item_strct
|
|
.attrs
|
|
.attrs
|
|
.iter()
|
|
.iter()
|
|
@@ -234,8 +233,8 @@ fn parse_events(ctx: &CrateContext) -> Vec<&syn::ItemStruct> {
|
|
})
|
|
})
|
|
.count();
|
|
.count();
|
|
match attrs_count {
|
|
match attrs_count {
|
|
- 0 => None,
|
|
|
|
- 1 => Some(item_strct),
|
|
|
|
|
|
+ 0 => false,
|
|
|
|
+ 1 => true,
|
|
_ => panic!("Invalid syntax: one event attribute allowed"),
|
|
_ => panic!("Invalid syntax: one event attribute allowed"),
|
|
}
|
|
}
|
|
})
|
|
})
|
|
@@ -244,7 +243,7 @@ fn parse_events(ctx: &CrateContext) -> Vec<&syn::ItemStruct> {
|
|
|
|
|
|
fn parse_accounts(ctx: &CrateContext) -> Vec<&syn::ItemStruct> {
|
|
fn parse_accounts(ctx: &CrateContext) -> Vec<&syn::ItemStruct> {
|
|
ctx.structs()
|
|
ctx.structs()
|
|
- .filter_map(|item_strct| {
|
|
|
|
|
|
+ .filter(|item_strct| {
|
|
let attrs_count = item_strct
|
|
let attrs_count = item_strct
|
|
.attrs
|
|
.attrs
|
|
.iter()
|
|
.iter()
|
|
@@ -254,9 +253,9 @@ fn parse_accounts(ctx: &CrateContext) -> Vec<&syn::ItemStruct> {
|
|
})
|
|
})
|
|
.count();
|
|
.count();
|
|
match attrs_count {
|
|
match attrs_count {
|
|
- 0 => None,
|
|
|
|
- 1 => Some(item_strct),
|
|
|
|
- _ => panic!("Invalid syntax: one event attribute allowed"),
|
|
|
|
|
|
+ 0 => false,
|
|
|
|
+ 1 => true,
|
|
|
|
+ _ => panic!("Invalid syntax: one account attribute allowed"),
|
|
}
|
|
}
|
|
})
|
|
})
|
|
.collect()
|
|
.collect()
|