Deque
A fixed size VecDeque for Rust to match
the Python Deque functionality.
Implemented as a thin wrapper around std::collections::VecDeque with custom handling for push_back and push_front
that prevents the VecDeque from growing past the set maximum length.
Once the deque is full, when a new item is pushed to the deque, an element from the opposite end 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!;
assert_eq!;
let mut deque = from_vec;
assert_eq!;
let popped = deque.push_back;
assert_eq!;
assert_eq!;
let mut deque: = .into;
assert_eq!;
assert_eq!;
assert_eq!;
deque.push_front;
deque.push_front;
deque.push_front;
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.
- Always add test cases for new functionality
- Ensure that code is formatted with
cargo fmtandcargo clippy --all-featurespasses
License
MIT