Deque
A fixed size VecDeque for Rust to match
the Python Deque.
Implemented as a thin wrapper around std::collections::VecDeque with custom handling for push_back
that prevents the VecDeque from growing past the set maximum length.
Once the deque is full, when a new item is added to the back, the front element is popped and returned.
use Deque;
let mut deque: = new;
deque.push_back;
deque.push_back;
deque.push_back;
deque.push_back;
assert_eq!;
assert_eq!;
deque = new_from_vec;
assert_eq!;
let overflow = deque.push_back;
assert_eq!;
assert_eq!;
Features
Optional serde feature that adds support for (de)serializing the Deque.
cargo add fixed_deque --features serde
Contribution
Contributions are very welcome. If you feel something could be added or improved, please do open a PR.
License
MIT