rl_lang/interpreter/stdlib/array/arr_is_empty.rs
1use crate::{
2 interpreter::{evaluator::Evaluator, values::Value},
3 utils::{errors::Error, span::Span},
4};
5
6pub fn std_arr_is_empty(eval: &mut Evaluator, array: Value, span: Span) -> Result<bool, Error> {
7 match array {
8 Value::Values { items, .. } => {
9 if items.is_empty() {
10 return Ok(true);
11 }
12 Ok(false)
13 }
14 _ => Err(eval.err("arr_is_empty() accepts only arrays".to_string(), span)),
15 }
16}