pub struct Stack { /* private fields */ }Expand description
A bounded stack of PsObject values.
Implementations§
Source§impl Stack
impl Stack
pub fn new(max_size: usize) -> Self
Sourcepub fn push(&mut self, obj: PsObject) -> Result<(), PsError>
pub fn push(&mut self, obj: PsObject) -> Result<(), PsError>
Push an object, returning StackOverflow if full.
Sourcepub fn insert_at(&mut self, index: usize, obj: PsObject) -> Result<(), PsError>
pub fn insert_at(&mut self, index: usize, obj: PsObject) -> Result<(), PsError>
Insert an object at a specific index from the bottom.
Used by the ExecArray inner loop to insert a continuation cursor below items that an operator just pushed to e_stack.
Sourcepub fn pop(&mut self) -> Result<PsObject, PsError>
pub fn pop(&mut self) -> Result<PsObject, PsError>
Pop the top object, returning StackUnderflow if empty.
Sourcepub fn peek(&self, from_top: usize) -> Result<PsObject, PsError>
pub fn peek(&self, from_top: usize) -> Result<PsObject, PsError>
Peek at an object relative to top. 0 = top, 1 = second from top, etc.
Sourcepub fn peek_mut(&mut self, from_top: usize) -> Result<&mut PsObject, PsError>
pub fn peek_mut(&mut self, from_top: usize) -> Result<&mut PsObject, PsError>
Mutable peek at an object relative to top.
pub fn len(&self) -> usize
pub fn is_empty(&self) -> bool
pub fn clear(&mut self)
Sourcepub fn set_max_size(&mut self, max_size: usize)
pub fn set_max_size(&mut self, max_size: usize)
Update the maximum stack size.
pub fn as_slice(&self) -> &[PsObject]
pub fn as_mut_slice(&mut self) -> &mut [PsObject]
pub fn truncate(&mut self, len: usize)
Sourcepub fn swap_top_two(&mut self) -> Result<(), PsError>
pub fn swap_top_two(&mut self) -> Result<(), PsError>
Swap the top two elements (for exch).
Auto Trait Implementations§
impl Freeze for Stack
impl RefUnwindSafe for Stack
impl Send for Stack
impl Sync for Stack
impl Unpin for Stack
impl UnsafeUnpin for Stack
impl UnwindSafe for Stack
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