pub trait StackOperations {
// Required methods
fn push(&mut self, value: Value);
fn pop(&mut self) -> Option<Value>;
fn peek(&self) -> Option<&Value>;
fn clear(&mut self);
fn len(&self) -> usize;
fn is_empty(&self) -> bool;
fn stack_mut(&mut self) -> &mut Stack;
// Provided method
fn size(&self) -> usize { ... }
}Expand description
Defines operations for manipulating the VM’s operand stack
This trait provides the interface for all stack operations including pushing, popping, and inspecting stack contents.
Required Methods§
Sourcefn pop(&mut self) -> Option<Value>
fn pop(&mut self) -> Option<Value>
Pops a value from the top of the stack
§Returns
Some(value)if the stack is not emptyNoneif the stack is empty
Sourcefn peek(&self) -> Option<&Value>
fn peek(&self) -> Option<&Value>
Peeks at the top value without removing it
§Returns
Some(&value)if the stack is not emptyNoneif the stack is empty