pub enum Expr {
Show 14 variants
Literal(Value),
Call {
op: String,
args: Vec<Expr>,
},
Let {
bindings: Vec<(String, Expr)>,
body: Box<Expr>,
},
Var(String),
Match {
input: Box<Expr>,
arms: Vec<(Vec<Value>, Expr)>,
default: Box<Expr>,
},
Step {
input: Box<Expr>,
output0: Box<Expr>,
stops: Vec<(f64, Expr)>,
},
Interpolate {
kind: InterpKind,
space: InterpSpace,
input: Box<Expr>,
stops: Vec<(f64, Expr)>,
projection: bool,
},
Format(Vec<FormatArg>),
Within(Vec<Vec<Vec<(f64, f64)>>>),
Distance(Vec<SimpleGeom>),
Collator {
case_sensitive: Option<Box<Expr>>,
diacritic_sensitive: Option<Box<Expr>>,
locale: Option<Box<Expr>>,
},
NumberFormat {
value: Box<Expr>,
locale: Option<Box<Expr>>,
currency: Option<Box<Expr>>,
min_fraction_digits: Option<Box<Expr>>,
max_fraction_digits: Option<Box<Expr>>,
unit: Option<Box<Expr>>,
},
Assert(Type, Box<Expr>),
Coerce(Type, Box<Expr>),
}Expand description
A parsed MapLibre expression.
Most operators are represented uniformly as Expr::Call; the handful of
operators with irregular argument shapes (bindings, unquoted match labels,
stop lists) get dedicated variants so evaluation stays simple.
Variants§
Literal(Value)
A constant value (bare literal or the literal operator).
Call
A generic operator call whose arguments are all sub-expressions.
Let
["let", name, value, ..., body]
Var(String)
["var", name]
Match
["match", input, label, output, ..., default]
Step
["step", input, output0, stop1, output1, ...]
Interpolate
["interpolate"|"interpolate-hcl"|"interpolate-lab", type, input, stop, output, ...]
Format(Vec<FormatArg>)
["format", content, options?, ...] — styled text sections.
Within(Vec<Vec<Vec<(f64, f64)>>>)
["within", geojson] — the argument polygons as [lng, lat] rings
(a multipolygon: list of polygons, each a list of rings).
Distance(Vec<SimpleGeom>)
["distance", geojson] — the argument geometries in [lng, lat].
Collator
["collator", options] — a locale-aware string collator.
Fields
NumberFormat
["number-format", value, options].
Fields
Assert(Type, Box<Expr>)
A runtime type assertion inserted by type checking: the inner expression must already produce the given type at runtime, or evaluation errors.
Coerce(Type, Box<Expr>)
A runtime coercion inserted by type checking: the inner expression’s value is converted to the given type (e.g. string → color).
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Expr
impl RefUnwindSafe for Expr
impl Send for Expr
impl Sync for Expr
impl Unpin for Expr
impl UnsafeUnpin for Expr
impl UnwindSafe for Expr
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> ErasedDestructor for Twhere
T: 'static,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more