rl_lang/interpreter/stdlib/path/path_is_file.rs
1use crate::{
2 interpreter::{evaluator::Evaluator, values::Value},
3 utils::{errors::Error, span::Span},
4};
5
6pub fn std_path_is_file(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_file())),
9 other => Err(eval.err(
10 format!("path_is_file() expects a string, got {}", other.type_name()),
11 span,
12 )),
13 }
14}