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

Add resolution method option to associated-derive #1

Open
ZacJW opened this issue Nov 12, 2021 · 0 comments
Open

Add resolution method option to associated-derive #1

ZacJW opened this issue Nov 12, 2021 · 0 comments

Comments

@ZacJW
Copy link
Owner

ZacJW commented Nov 12, 2021

Currently associated-derive uses match to resolve which constant it should return. This is fine when used with enums with consecutive discriminants or non-consecutive but not too sparse as Rust will compile the match to a jump table (even in debug builds).

However if the discriminants are very sparse, it will fall back to checking one-by-one which is linear time complexity with the number of variants.

Having other resultion methods, like some sort of binary search or a precomputed static hash table, could be very useful in those circumstances. Before they can be built, the user needs a way to chose which method to use, currently just "Match".

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

No branches or pull requests

1 participant