pub struct Stack<V: Copy, const N: usize> { /* private fields */ }
Expand description
This is a simplest and the fastest implementation of a stack on stack,
when stack elements are Copy
implementing primitives.
For example, here is how a stack can be created:
use microstack::Stack;
let mut s : Stack<u64, 10> = Stack::new();
s.push(1);
s.push(2);
assert_eq!(2, s.pop());
Implementations§
Source§impl<V: Copy, const N: usize> Stack<V, N>
impl<V: Copy, const N: usize> Stack<V, N>
Sourcepub unsafe fn push_unchecked(&mut self, v: V)
pub unsafe fn push_unchecked(&mut self, v: V)
Sourcepub fn try_push(&mut self, v: V) -> Result<(), String>
pub fn try_push(&mut self, v: V) -> Result<(), String>
Makes an attempt to push a new element into the stack.
If there was enough space in the stack, Ok(v)
is returned, while
Err
is returned otherwise.
§Errors
If there is not enough space in the stack, Err
is returned.
Sourcepub unsafe fn pop_unchecked(&mut self) -> V
pub unsafe fn pop_unchecked(&mut self) -> V
Trait Implementations§
Auto Trait Implementations§
impl<V, const N: usize> Freeze for Stack<V, N>where
V: Freeze,
impl<V, const N: usize> RefUnwindSafe for Stack<V, N>where
V: RefUnwindSafe,
impl<V, const N: usize> Send for Stack<V, N>where
V: Send,
impl<V, const N: usize> Sync for Stack<V, N>where
V: Sync,
impl<V, const N: usize> Unpin for Stack<V, N>where
V: Unpin,
impl<V, const N: usize> UnwindSafe for Stack<V, N>where
V: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more