Here is an implementation of a ring buffer in Rust:
main.rs795 chars33 lines
The new
function creates a new ring buffer with the specified size. The push
function adds an item to the buffer, wrapping around to the beginning if necessary. The pop
function removes and returns the oldest item from the buffer.
gistlibby LogSnag