ladata/list/stack/
data.rs

1// ladata::list::stack::data
2//
3//! `DataStack` abstract data type.
4//
5
6use super::{Stack, Storage};
7use crate::all::{DataCollection, LadataResult as Result};
8
9/// An abstract Stack.
10pub trait DataStack: DataCollection {
11    ///
12    fn stack_pop(&mut self) -> Result<<Self as DataCollection>::Element>;
13    ///
14    fn stack_push(&mut self, element: <Self as DataCollection>::Element) -> Result<()>;
15}
16
17impl<T, S: Storage, const CAP: usize> DataCollection for Stack<T, S, CAP> {
18    type Element = T;
19
20    fn collection_is_empty(&self) -> Option<bool> {
21        Some(self.is_empty())
22    }
23    fn collection_is_full(&self) -> Option<bool> {
24        Some(self.is_full())
25    }
26    fn collection_capacity(&self) -> usize {
27        CAP
28    }
29    fn collection_len(&self) -> usize {
30        self.len()
31    }
32}