pub struct Stack<T> { /* private fields */ }Implementations§
Source§impl<T> Stack<T>
impl<T> Stack<T>
Sourcepub fn new() -> Self
pub fn new() -> Self
Creates a new empty stack.
§Examples
use RustyDSA::data_structure::stack::Stack;
let stack: Stack<i32> = Stack::new();Sourcepub fn push(&mut self, element: T)
pub fn push(&mut self, element: T)
Adds elements to the stack.
§Examples
use RustyDSA::data_structure::stack::Stack;
let mut stack: Stack<i32> = Stack::new();
stack.push(1);
assert!(!stack.is_null());Sourcepub fn pop(&mut self) -> Option<T>
pub fn pop(&mut self) -> Option<T>
Removes and returns an element from the stack.
Returns None if the stack is empty.
§Examples
use RustyDSA::data_structure::stack::Stack;
let mut stack: Stack<i32> = Stack::new();
stack.push(1);
let element = stack.pop();
assert_eq!(element, Some(1));Trait Implementations§
Auto Trait Implementations§
impl<T> Freeze for Stack<T>
impl<T> RefUnwindSafe for Stack<T>where
Vec<T>: RefUnwindSafe,
impl<T> Send for Stack<T>
impl<T> Sync for Stack<T>
impl<T> Unpin for Stack<T>
impl<T> UnsafeUnpin for Stack<T>where
Vec<T>: UnsafeUnpin,
impl<T> UnwindSafe for Stack<T>where
Vec<T>: 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