New features
This release restructures the crate around three types that mirror the relationship between Rust's slice, array, and Vec:
CircularBuffer<T>: a new unsized "reference" type that holds the core logic (analogous to a slice[T]).FixedCircularBuffer<T, N>: the fixed-capacity, stack-allocatable buffer (analogous to an array[T; N]). This is the new name for what used to beCircularBuffer<N, T>in version 1 of the crate.HeapCircularBuffer<T>: a new heap-allocated buffer whose capacity can be set at runtime (analogous toVec<T>).
Breaking changes
- Renamed the fixed-capacity buffer from
CircularBuffer<N, T>toFixedCircularBuffer<T, N>. Note that the order of the generic parameters has also changed (to be more consistent with the order of parameters in Rust's array type). For example,CircularBuffer<16, u32>becomesFixedCircularBuffer<u32, 16>. - The struct
CircularBufferis now the unsized type described above, no longer the owned fixed-size buffer. - Removed the deprecated
use_stdcargo feature; usestdinstead. - Removed the
unstablecargo feature. All the code in this crate now uses fully stable Rust. - Increased the minimum supported Rust version from 1.87 to 1.93.
Bug fixes
- Fixed a panic in
drain()when called on a zero-capacity buffer. - Fixed
try_push_back()andtry_push_front()on zero-capacity buffers. The
methods used to discard the specified item; now they return it as anErr. - Fixed a potential double-drop in the
From<[T; M]>implementation forFixedCircularBufferthat could occur when an element'sDropimplementation panicked.
Other changes
- Performance improvements for the
Cloneimplementation.