Enum jrsonnet_parser::Expr[][src]

pub enum Expr {
Show variants Literal(LiteralType), Str(IStr), Num(f64), Var(IStr), Arr(Vec<LocExpr>), ArrComp(LocExprVec<CompSpec>), Obj(ObjBody), ObjExtend(LocExprObjBody), Parened(LocExpr), UnaryOp(UnaryOpTypeLocExpr), BinaryOp(LocExprBinaryOpTypeLocExpr), AssertExpr(AssertStmtLocExpr), LocalExpr(Vec<BindSpec>, LocExpr), Import(PathBuf), ImportStr(PathBuf), ErrorStmt(LocExpr), Apply(LocExprArgsDescbool), Index(LocExprLocExpr), Function(ParamsDescLocExpr), Intrinsic(IStr), IfElse { cond: IfSpecData, cond_then: LocExpr, cond_else: Option<LocExpr>, },
}
Expand description

Syntax base

Variants

Literal(LiteralType)
Str(IStr)

String value: “hello”

Num(f64)

Number: 1, 2.0, 2e+20

Var(IStr)

Variable name: test

Arr(Vec<LocExpr>)

Array of expressions: [1, 2, “Hello”]

ArrComp(LocExprVec<CompSpec>)

Array comprehension:

 ingredients: [
   { kind: kind, qty: 4 / 3 }
   for kind in [
     'Honey Syrup',
     'Lemon Juice',
     'Farmers Gin',
   ]
 ],
Obj(ObjBody)

Object: {a: 2}

ObjExtend(LocExprObjBody)

Object extension: var1 {b: 2}

Parened(LocExpr)

(obj)

UnaryOp(UnaryOpTypeLocExpr)

-2

2 - 2

AssertExpr(AssertStmtLocExpr)

assert 2 == 2 : “Math is broken”

LocalExpr(Vec<BindSpec>, LocExpr)

local a = 2; { b: a }

Import(PathBuf)

import “hello”

ImportStr(PathBuf)

importStr “file.txt”

ErrorStmt(LocExpr)

error “I’m broken”

Apply(LocExprArgsDescbool)

a(b, c)

Index(LocExprLocExpr)

a[b]

Function(ParamsDescLocExpr)

function(x) x

Intrinsic(IStr)

std.primitiveEquals

IfElse

if true == false then 1 else 2

Show fields

Fields of IfElse

cond: IfSpecDatacond_then: LocExprcond_else: Option<LocExpr>

Trait Implementations

Formats the value using the given formatter. Read more

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.