pub enum NumericExpression {
Show 16 variants
Literal(f64),
Zoom,
Pitch,
GetProperty {
key: String,
fallback: f64,
},
GetState {
key: String,
fallback: f64,
},
Add(Box<NumericExpression>, Box<NumericExpression>),
Sub(Box<NumericExpression>, Box<NumericExpression>),
Mul(Box<NumericExpression>, Box<NumericExpression>),
Div(Box<NumericExpression>, Box<NumericExpression>),
Mod(Box<NumericExpression>, Box<NumericExpression>),
Pow(Box<NumericExpression>, Box<NumericExpression>),
Abs(Box<NumericExpression>),
Ln(Box<NumericExpression>),
Sqrt(Box<NumericExpression>),
Min(Box<NumericExpression>, Box<NumericExpression>),
Max(Box<NumericExpression>, Box<NumericExpression>),
}Expand description
A numeric expression that evaluates to f64.
Used as the input for Interpolate and Step expressions, and as
operands for arithmetic and comparison operations.
Variants§
Literal(f64)
A constant numeric literal.
Zoom
The current map zoom level.
Pitch
The current camera pitch in degrees.
GetProperty
Read a numeric feature property.
GetState
Read a numeric feature-state value.
Add(Box<NumericExpression>, Box<NumericExpression>)
Addition: a + b.
Sub(Box<NumericExpression>, Box<NumericExpression>)
Subtraction: a - b.
Mul(Box<NumericExpression>, Box<NumericExpression>)
Multiplication: a * b.
Div(Box<NumericExpression>, Box<NumericExpression>)
Division: a / b (returns 0 on division by zero).
Mod(Box<NumericExpression>, Box<NumericExpression>)
Remainder: a % b.
Pow(Box<NumericExpression>, Box<NumericExpression>)
Exponentiation: a ^ b.
Abs(Box<NumericExpression>)
Absolute value.
Ln(Box<NumericExpression>)
Natural logarithm.
Sqrt(Box<NumericExpression>)
Square root.
Min(Box<NumericExpression>, Box<NumericExpression>)
Minimum of two values.
Max(Box<NumericExpression>, Box<NumericExpression>)
Maximum of two values.
Implementations§
Source§impl NumericExpression
impl NumericExpression
Sourcepub fn eval(&self, ctx: &ExprEvalContext<'_>) -> f64
pub fn eval(&self, ctx: &ExprEvalContext<'_>) -> f64
Evaluate this numeric expression against a context.
Trait Implementations§
Source§impl Clone for NumericExpression
impl Clone for NumericExpression
Source§fn clone(&self) -> NumericExpression
fn clone(&self) -> NumericExpression
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for NumericExpression
impl Debug for NumericExpression
Source§impl PartialEq for NumericExpression
impl PartialEq for NumericExpression
impl StructuralPartialEq for NumericExpression
Auto Trait Implementations§
impl Freeze for NumericExpression
impl RefUnwindSafe for NumericExpression
impl Send for NumericExpression
impl Sync for NumericExpression
impl Unpin for NumericExpression
impl UnsafeUnpin for NumericExpression
impl UnwindSafe for NumericExpression
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
Mutably borrows from an owned value. Read more