circular_vec 0.1.1

A fixed length vector that provides a next function that loops infinitely
Documentation
  • Coverage
  • 100%
    4 out of 4 items documented1 out of 4 items with examples
  • Size
  • Source code size: 5.34 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 1.32 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Links
  • banool/circular_vec
    0 1 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • banool

Circular Vec

This provides a struct called CircularVec. It is a fixed length Vec that provides a next function, which iterates through the vec. When it hits the end, instead of returning None, we just loop back to the start.

Note: This struct could use a lot of love. While I do have a need for this struct, and I use this for a personal project, this is also to become familiar with publishing a crate to crates.io. See the many ways this could be improved below.

Future work

  • This is likely not as efficient as it could be. We use Vec internally, which can grow, but we don't need that.
  • We could export a version of this that can change size. Shrink semantics TBA.
  • This doesn't implement many traits that it could. See the traits that Vec implements for inspiration.
  • The API could probably use some love, like exposing this as an iterator instead of providing a next function.
  • Probably much much more.