mln-rs-expression 0.0.7

Part of mln-rs, a Rust port of the MapLibre Native map rendering core. Depend on mln-rs instead.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
// Ports include/mln/style/expression/is_expression.hpp and
// src/mln/style/expression/is_expression.cpp.

use crate::compound_expression::CompoundExpression;
use crate::parsing_context::is_expression_name;
use mln_conversion::Convertible;

pub fn is_expression(value: &Convertible<'_>) -> bool {
    if !value.is_array() || value.array_length() == 0 {
        return false;
    }
    let Some(name) = value.array_member(0).to_string() else {
        return false;
    };

    is_expression_name(&name) || CompoundExpression::exists(&name)
}