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 a size parameter for ConstGenericRingBuffer::new #110

Merged
merged 1 commit into from
Sep 15, 2023

Conversation

tertsdiepraam
Copy link
Contributor

@tertsdiepraam tertsdiepraam commented Jun 8, 2023

This is a minor ergonomic improvement which allows us to write:

ConstGenericRingBuffer::new::<5>()

instead of

ConstGenericRingBuffer::<_, 5>::new()

when the type can be inferred, saving a grand total of 2 characters (3 if you count the space)!

This trick (ab)uses From as a stand-in for an identity trait. This is probably fine, because there is only one possible implementation of the from method, which is the identity function, since From is guaranteed to be reflexive via a blanket impl.

@tertsdiepraam tertsdiepraam changed the title Add a size parameter for ConstGenericRingBuffer::new Add a size parameter for ConstGenericRingBuffer::new Jun 8, 2023
@jdonszelmann
Copy link
Collaborator

I kinda like this @NULLx76, what're your thoughts?

@jdonszelmann jdonszelmann merged commit 5c75226 into NULLx76:main Sep 15, 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.

3 participants