lifo

Crates.iolifo
lib.rslifo
version0.1.1
sourcesrc
created_at2024-10-23 10:06:57.686455
updated_at2024-10-23 11:37:44.24227
descriptionSimple last-in first-out api wrapper for std `VecDeque`.
homepage
repositoryhttps://github.com/Da1sypetals/lifo
max_upload_size
id1419909
size2,721
(Da1sypetals)

documentation

README

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()
    }
}
Commit count: 4

cargo fmt