Trait ArrayBehavior

Source
pub trait ArrayBehavior {
    // Required method
    fn pop(&mut self) -> Option<Value>;
}

Required Methods§

Source

fn pop(&mut self) -> Option<Value>

Removes the last element from the array and returns it, or None if the array is empty.

§Examples
use my_crate::{Array, Value};

let mut array = Array::new();
array.push(Value::from(42));

let popped_value = array.pop();
assert_eq!(popped_value, Some(Value::from(42)));

let empty_array = Array::new();
let empty_popped_value = empty_array.pop();
assert_eq!(empty_popped_value, None);

Implementors§