-
Notifications
You must be signed in to change notification settings - Fork 11.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[framework] Adds bcs::peel_enum_tag
#20984
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
2 Skipped Deployments
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am thinking that this shouldn't really be a macro after some further reading.
peel_vec
and peel_option
both have a return type of their constructing type--vector
and Option
respectively.
But peel_enum
here is just passing back the return value of peel_enum_tag
.
For example
public macro fun peel_enum<$T>($bcs: &mut BCS, $f: |u64| -> $T): $T
...
bcs.peel_enum!(|tag| match (tag) {
0 => Enum::Empty,
1 => Enum::U8(bcs.peel_u8()),
2 => Enum::U16(bcs.peel_u16()),
_ => abort,
}
could just be
public fun peel_enum_tag(bcs: &mut BCS): u64
...
match (peel_enum_tag(tag)) {
0 => Enum::Empty,
1 => Enum::U8(bcs.peel_u8()),
2 => Enum::U16(bcs.peel_u16()),
_ => abort,
}
TLDR the macro is just function application, which isn't really that interesting I think?
39a290e
to
de1d889
Compare
de1d889
to
4c06829
Compare
c0d647e
to
9652690
Compare
peel_enum
to bcsbcs::peel_enum_tag
Description
Minor improvement for
bcs
library, helper to parse enums.Test plan
Features tests.
Release notes
Check each box that your changes affect. If none of the boxes relate to your changes, release notes aren't required.
For each box you select, include information after the relevant heading that describes the impact of your changes that a user might notice and any actions they must take to implement updates.
bcs::peel_enum_tag
function