Expand description
Fixed-size, stack-allocated ring buffer — no heap, no alloc, no atomics.
RingBuf is a single-owner (&mut self) ring that overwrites the
oldest element when full. It requires only T: Copy and is ideal for
sample windows, local event logs, and anywhere a simple circular buffer
is needed without cross-thread sharing.
Slots are MaybeUninit<T> and only live entries are ever read, which is
what lets the Default bound go. The cost is that this type is no longer
free of unsafe: see the safety note on RingBuf.
For a lock-free SPSC ring with sequence tracking, see crate::SeqRing.
For a lock-free SPSC ring with backpressure, see crate::EventBuf.
§Example
use ph_eventing::RingBuf;
let mut r = RingBuf::<u32, 4>::new();
r.push(10);
r.push(20);
assert_eq!(r.latest(), Some(20));
assert_eq!(r.get(0), Some(10)); // oldest