ringbuffer icon indicating copy to clipboard operation
ringbuffer copied to clipboard

`RingBuffer` API Suggestions

Open tertsdiepraam opened this issue 9 months ago • 0 comments

I took a look at the API of the RingBuffer trait and I have some suggestions for cleanup before 1.0. Happy to make a PR for whatever subset of these changes you want (except the second one, I'd need to investigate that with one of you to fully figure that out):

  • [x] Swap push and enqueue. Since dequeue is a required method on RingBuffer, is makes sense that enqueue would be the required method and push the provided one.
  • [ ] len being provided is a bit confusing, because there's no way it can be derived from the required methods, at least not from the methods that show up in the docs. Something you might consider is splitting RingBuffer from UnsafeRingBuffer or something and "hide" methods that way, while still making it possible to see what's going on in the docs. Ideally though, the ptr_* methods would only be an implementation detail and should maybe not be part of the trait.
  • [ ] get_signed can probably be a provided method, based on length and get.
  • [ ] skip seems like it could be removed, because the drop can be done manually.

tertsdiepraam avatar Sep 24 '23 16:09 tertsdiepraam