Skip to main content

rl_lang/interpreter/stdlib/path/
path_is_dir.rs

1use crate::{
2    interpreter::{evaluator::Evaluator, values::Value},
3    utils::{errors::Error, span::Span},
4};
5
6pub fn std_path_is_dir(eval: &mut Evaluator, path: Value, span: Span) -> Result<Value, Error> {
7    match path {
8        Value::String(s) => Ok(Value::Bool(std::path::Path::new(&s).is_dir())),
9        other => Err(eval.err(
10            format!("path_is_dir() expects a string, got {}", other.type_name()),
11            span,
12        )),
13    }
14}