pub struct ValueStack { /* private fields */ }Implementations§
Source§impl ValueStack
impl ValueStack
pub fn new(size: usize) -> Self
pub fn as_slice(&self) -> &[Value]
pub fn push<T: Into<Value>>(&mut self, value: T) -> Result<(), StackError>
pub fn clear(&mut self)
pub fn len(&self) -> usize
pub fn pop_n<const N: usize>(&mut self) -> [Value; N]
Sourcepub fn pop_w_offset(&mut self, offset: usize) -> Value
pub fn pop_w_offset(&mut self, offset: usize) -> Value
Pop value, treating offset as the 0 position
use cao_lang::collections::value_stack::ValueStack;
use cao_lang::prelude::Value;
let mut stack = ValueStack::new(4);
stack.push(Value::Integer(42));
let res = stack.pop_w_offset(1);
assert_eq!(res, Value::Nil);
let res = stack.pop();
assert_eq!(res, Value::Integer(42));Sourcepub fn set(&mut self, index: usize, value: Value) -> Result<Value, StackError>
pub fn set(&mut self, index: usize, value: Value) -> Result<Value, StackError>
Sets a value Only previous values may be set
Returns the old value
pub fn get(&mut self, index: usize) -> Value
Sourcepub fn clear_until(&mut self, index: usize) -> Value
pub fn clear_until(&mut self, index: usize) -> Value
Returns the very first item
pub fn is_empty(&self) -> bool
pub fn iter(&self) -> impl Iterator<Item = Value>
pub fn top_location(&self) -> *const Value
Trait Implementations§
Source§impl Debug for ValueStack
impl Debug for ValueStack
Auto Trait Implementations§
impl Freeze for ValueStack
impl !RefUnwindSafe for ValueStack
impl !Send for ValueStack
impl !Sync for ValueStack
impl Unpin for ValueStack
impl !UnwindSafe for ValueStack
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