2 releases
0.1.1 | Oct 23, 2024 |
---|---|
0.1.0 | Oct 23, 2024 |
#2 in #pop
3KB
Lifo
Simple last-in first-out api wrapper for std VecDeque<T>
.
Code
use std::collections::VecDeque;
pub type Deque<T> = VecDeque<T>;
/// ### Defaults the behavior of `push` and `pop`.
pub trait Lifo<T> {
fn push(&mut self, value: T);
fn pop(&mut self) -> Option<T>;
}
impl<T> Lifo<T> for Deque<T> {
/// ### Push back
#[inline(always)]
fn push(&mut self, value: T) {
self.push_back(value);
}
/// ### Pop front
#[inline(always)]
fn pop(&mut self) -> Option<T> {
self.pop_front()
}
}