boxed_array_ringbuffer

Crates.ioboxed_array_ringbuffer
lib.rsboxed_array_ringbuffer
version0.1.1
sourcesrc
created_at2021-12-12 19:47:12.465342
updated_at2021-12-12 20:01:01.935858
descriptionA ring buffer of fixed size, that uses a boxed array as storage, therefore avoiding re-allocations when converting from Vec or to VecDeque.
homepage
repositoryhttps://github.com/soulsource/boxed_array_ringbuffer
max_upload_size
id496693
size23,923
Andreas Grois (soulsource)

documentation

README

boxed_array_ringbuffer

Rust Ring Buffer that uses a boxed array as backing storage, to guarantee a fixed size after initialization. Uses const generics.

This crate is useful in cases where one needs an as simple as possible queue of a fixed size, and wants that fixed size to be guaranteed. The standard library offers a double ended queue of variable size, VecDeque, but there might be cases in which one does not want the used queue to possibly ever grow or shrink, for instance to avoid bugs by making invaild states unrepresentable.

Storage of the ring buffer is in the heap, because that way Vec or Box<[_]> can be converted into a RingBuffer without any re-allocations, and a RingBuffer can be converted into a VecDeque without re-allocations too.

See the documentation on https://docs.rs/boxed_array_ringbuffer for details on how to use it.

This crate does not (directly) use any unsafe code, and only has the standard library as dependency.

Commit count: 8

cargo fmt