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

feat: add missing new functions for byte types #380

Merged
merged 2 commits into from
Nov 13, 2023

Conversation

mattsse
Copy link
Contributor

@mattsse mattsse commented Nov 11, 2023

currently there's no infallible way to create Bytes types

This adds new(array) -> Self functions

@jtraglia
Copy link
Member

Hey @mattsse. There are functions for this here (might need to scroll btw):

impl From<[u8; BYTES_PER_BLOB]> for Blob {
fn from(value: [u8; BYTES_PER_BLOB]) -> Self {
Self { bytes: value }
}
}
impl From<[u8; 32]> for Bytes32 {
fn from(value: [u8; 32]) -> Self {
Self { bytes: value }
}
}
impl From<[u8; 48]> for Bytes48 {
fn from(value: [u8; 48]) -> Self {
Self { bytes: value }
}
}

@mattsse
Copy link
Contributor Author

mattsse commented Nov 13, 2023

ah

hmm, I think having a const fn new would still be useful if you want to define constants

Copy link
Member

@jtraglia jtraglia left a comment

Choose a reason for hiding this comment

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

hmm, I think having a const fn new would still be useful if you want to define constants

Alright yeah, I'm okay with this if it makes things easier for you guys. Just two minor nits.

It's pretty simple, but I'd appreciate another review by @pawanjay176 or @asn-d6 before merging.

Copy link
Member

@jtraglia jtraglia left a comment

Choose a reason for hiding this comment

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

LGTM 👍 On second thought, this is so minor I feel comfortable merging it now. Thanks!

@jtraglia jtraglia merged commit 712ccb6 into ethereum:main Nov 13, 2023
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