https://github.com/banool/circular_vec
https://github.com/banool/circular_vec
Last synced: about 1 year ago
JSON representation
- Host: GitHub
- URL: https://github.com/banool/circular_vec
- Owner: banool
- Created: 2021-07-24T00:24:40.000Z (almost 5 years ago)
- Default Branch: main
- Last Pushed: 2021-07-24T01:31:00.000Z (almost 5 years ago)
- Last Synced: 2025-03-14T23:43:22.527Z (over 1 year ago)
- Language: Rust
- Size: 1.95 KB
- Stars: 0
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# 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](https://doc.rust-lang.org/std/vec/struct.Vec.html) 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.