NULLx76 / ringbuffer

A fixed-size circular buffer written in Rust.
https://crates.io/crates/ringbuffer
MIT License
95 stars 20 forks source link

Add a size parameter for `ConstGenericRingBuffer::new` #110

Closed tertsdiepraam closed 1 year ago

tertsdiepraam commented 1 year ago

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.

jdonszelmann commented 1 year ago

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