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: split Chain into a struct and ChainKind enum #5

Merged
merged 1 commit into from
Nov 14, 2023

Conversation

DaniPopes
Copy link
Member

@DaniPopes DaniPopes commented Nov 14, 2023

Instead of checking whether Self::Id(_) can be converted into a NamedChain everywhere, we can enforce this at construction by making Chain a struct with a hidden inner ChainKind enum.

By making the fields private, we also make room for potential optimizations in the future, such as reducing the size of Chain from 16 to 8 bytes.

@DaniPopes DaniPopes force-pushed the dani/chain-struct branch 2 times, most recently from f36dd50 to 1984db9 Compare November 14, 2023 14:50
Copy link
Member

@mattsse mattsse left a comment

Choose a reason for hiding this comment

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

I like this

pending @Evalir

]
}
}

impl Chain {
Copy link
Member

Choose a reason for hiding this comment

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

can we move this below the struct def?

Copy link
Member Author

Choose a reason for hiding this comment

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

I prefer trait impls blocks before main impl, that's how I did it in all of core

Copy link
Member

Choose a reason for hiding this comment

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

I'm used to above trait impls -.-

but I don't mind

Copy link
Contributor

@Evalir Evalir left a comment

Choose a reason for hiding this comment

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

Super nice. I like implemeting traits first too, so agree

By making the fields private, we also make room for potential optimizations in the future, such as reducing the size of Chain from 16 to 8 bytes.

ahhh we're optimizingg

@DaniPopes DaniPopes merged commit 4e35dc0 into main Nov 14, 2023
20 checks passed
@DaniPopes DaniPopes deleted the dani/chain-struct branch November 14, 2023 17:54
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.

3 participants