#api #std #vec-deque #push #pop #vec-deque-t #first-out

lifo

Simple last-in first-out api wrapper for std VecDeque<T>

2 releases

0.1.1 Oct 23, 2024
0.1.0 Oct 23, 2024

#2 in #pop

Download history 242/week @ 2024-10-21 7/week @ 2024-10-28 8/week @ 2024-11-04

257 downloads per month

MIT/Apache

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()
    }
}

No runtime deps