Skip to content
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

More rusty and support shanghai fork #8

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

wtdcode
Copy link

@wtdcode wtdcode commented Jul 12, 2023

As title.

  1. Implement TryFrom
  2. Support Shanghai fork
  3. Now enum raw values are correct

Copy link
Owner

@ckoopmann ckoopmann left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

First of all thanks for the contribution and sorry for the late reply.🙏

Good idea to implement tryFrom, however I feel the implementation might be more verbose than it needs to be. What do you think ?


fn try_from(x: u8) -> Result<Self, Self::Error> {
match x {
x if x == Opcode::STOP as u8 => Ok(Opcode::STOP),
Copy link
Owner

@ckoopmann ckoopmann Oct 24, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems more verbose than the original mapping. I have a hunch there should be a more concise way to do this . Like using match to check wether the value matches any of the enum values in one line instead of 1 line for each enum variant. what do you think ?

SELFDESTRUCT = 255,
}

impl TryFrom<u8> for Opcode {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Generally good idea to implement tryFrom 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants