pub struct ExprBuilder<T> { /* private fields */ }
Expand description
Builder for constructing Expr
objects annotated with some data
(possibly taking default value) and optionally a source_loc
.
Implementations§
Source§impl<T> ExprBuilder<T>
impl<T> ExprBuilder<T>
Sourcepub fn with_expr_kind(self, expr_kind: ExprKind<T>) -> Expr<T>
pub fn with_expr_kind(self, expr_kind: ExprKind<T>) -> Expr<T>
Construct an Expr
containing the data
and source_loc
in this
ExprBuilder
and the given ExprKind
.
Sourcepub fn ite_arc(
self,
test_expr: Arc<Expr<T>>,
then_expr: Arc<Expr<T>>,
else_expr: Arc<Expr<T>>,
) -> Expr<T>
pub fn ite_arc( self, test_expr: Arc<Expr<T>>, then_expr: Arc<Expr<T>>, else_expr: Arc<Expr<T>>, ) -> Expr<T>
Create a ternary (if-then-else) Expr
.
Takes Arc
s instead of owned Expr
s.
test_expr
must evaluate to a Bool type
Sourcepub fn record_arc(self, map: Arc<BTreeMap<SmolStr, Expr<T>>>) -> Expr<T>
pub fn record_arc(self, map: Arc<BTreeMap<SmolStr, Expr<T>>>) -> Expr<T>
Create an Expr
which evaluates to a Record with the given key-value mapping.
If you have an iterator of pairs, generally prefer calling .record()
instead of .collect()
-ing yourself and calling this, potentially for
efficiency reasons but also because .record()
will properly handle
duplicate keys but your own .collect()
will not (by default).
Source§impl<T: Clone + Default> ExprBuilder<T>
impl<T: Clone + Default> ExprBuilder<T>
Sourcepub fn with_same_source_loc<U>(self, expr: &Expr<U>) -> Self
pub fn with_same_source_loc<U>(self, expr: &Expr<U>) -> Self
Utility used the validator to get an expression with the same source
location as an existing expression. This is done when reconstructing the
Expr
with type information.
Trait Implementations§
Source§impl<T: Clone> Clone for ExprBuilder<T>
impl<T: Clone> Clone for ExprBuilder<T>
Source§fn clone(&self) -> ExprBuilder<T>
fn clone(&self) -> ExprBuilder<T>
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreSource§impl<T: Debug> Debug for ExprBuilder<T>
impl<T: Debug> Debug for ExprBuilder<T>
Source§impl<T: Default + Clone> ExprBuilder for ExprBuilder<T>
impl<T: Default + Clone> ExprBuilder for ExprBuilder<T>
Source§fn val(self, v: impl Into<Literal>) -> Expr<T>
fn val(self, v: impl Into<Literal>) -> Expr<T>
Create an Expr
that’s just a single Literal
.
Note that you can pass this a Literal
, an Integer
, a String
, etc.
Source§fn ite(
self,
test_expr: Expr<T>,
then_expr: Expr<T>,
else_expr: Expr<T>,
) -> Expr<T>
fn ite( self, test_expr: Expr<T>, then_expr: Expr<T>, else_expr: Expr<T>, ) -> Expr<T>
Create a ternary (if-then-else) Expr
.
test_expr
must evaluate to a Bool type
Source§fn and(self, e1: Expr<T>, e2: Expr<T>) -> Expr<T>
fn and(self, e1: Expr<T>, e2: Expr<T>) -> Expr<T>
Create an ‘and’ expression. Arguments must evaluate to Bool type
Source§fn or(self, e1: Expr<T>, e2: Expr<T>) -> Expr<T>
fn or(self, e1: Expr<T>, e2: Expr<T>) -> Expr<T>
Create an ‘or’ expression. Arguments must evaluate to Bool type
Source§fn less(self, e1: Expr<T>, e2: Expr<T>) -> Expr<T>
fn less(self, e1: Expr<T>, e2: Expr<T>) -> Expr<T>
Create a ‘<’ expression. Arguments must evaluate to Long type
Source§fn lesseq(self, e1: Expr<T>, e2: Expr<T>) -> Expr<T>
fn lesseq(self, e1: Expr<T>, e2: Expr<T>) -> Expr<T>
Create a ‘<=’ expression. Arguments must evaluate to Long type
Source§fn add(self, e1: Expr<T>, e2: Expr<T>) -> Expr<T>
fn add(self, e1: Expr<T>, e2: Expr<T>) -> Expr<T>
Create an ‘add’ expression. Arguments must evaluate to Long type
Source§fn sub(self, e1: Expr<T>, e2: Expr<T>) -> Expr<T>
fn sub(self, e1: Expr<T>, e2: Expr<T>) -> Expr<T>
Create a ‘sub’ expression. Arguments must evaluate to Long type
Source§fn mul(self, e1: Expr<T>, e2: Expr<T>) -> Expr<T>
fn mul(self, e1: Expr<T>, e2: Expr<T>) -> Expr<T>
Create a ‘mul’ expression. Arguments must evaluate to Long type
Source§fn is_in(self, e1: Expr<T>, e2: Expr<T>) -> Expr<T>
fn is_in(self, e1: Expr<T>, e2: Expr<T>) -> Expr<T>
Create an ‘in’ expression. First argument must evaluate to Entity type. Second argument must evaluate to either Entity type or Set type where all set elements have Entity type.
Source§fn contains(self, e1: Expr<T>, e2: Expr<T>) -> Expr<T>
fn contains(self, e1: Expr<T>, e2: Expr<T>) -> Expr<T>
Create a ‘contains’ expression. First argument must have Set type.
Source§fn contains_all(self, e1: Expr<T>, e2: Expr<T>) -> Expr<T>
fn contains_all(self, e1: Expr<T>, e2: Expr<T>) -> Expr<T>
Create a ‘contains_all’ expression. Arguments must evaluate to Set type
Source§fn contains_any(self, e1: Expr<T>, e2: Expr<T>) -> Expr<T>
fn contains_any(self, e1: Expr<T>, e2: Expr<T>) -> Expr<T>
Create an ‘contains_any’ expression. Arguments must evaluate to Set type
Source§fn is_empty(self, expr: Expr<T>) -> Expr<T>
fn is_empty(self, expr: Expr<T>) -> Expr<T>
Create an ‘is_empty’ expression. Argument must evaluate to Set type
Source§fn get_tag(self, expr: Expr<T>, tag: Expr<T>) -> Expr<T>
fn get_tag(self, expr: Expr<T>, tag: Expr<T>) -> Expr<T>
Create a ‘getTag’ expression.
expr
must evaluate to Entity type, tag
must evaluate to String type.
Source§fn has_tag(self, expr: Expr<T>, tag: Expr<T>) -> Expr<T>
fn has_tag(self, expr: Expr<T>, tag: Expr<T>) -> Expr<T>
Create a ‘hasTag’ expression.
expr
must evaluate to Entity type, tag
must evaluate to String type.
Source§fn set(self, exprs: impl IntoIterator<Item = Expr<T>>) -> Expr<T>
fn set(self, exprs: impl IntoIterator<Item = Expr<T>>) -> Expr<T>
Create an Expr
which evaluates to a Set of the given Expr
s
Source§fn record(
self,
pairs: impl IntoIterator<Item = (SmolStr, Expr<T>)>,
) -> Result<Expr<T>, ExpressionConstructionError>
fn record( self, pairs: impl IntoIterator<Item = (SmolStr, Expr<T>)>, ) -> Result<Expr<T>, ExpressionConstructionError>
Create an Expr
which evaluates to a Record with the given (key, value) pairs.
Source§fn call_extension_fn(
self,
fn_name: Name,
args: impl IntoIterator<Item = Expr<T>>,
) -> Expr<T>
fn call_extension_fn( self, fn_name: Name, args: impl IntoIterator<Item = Expr<T>>, ) -> Expr<T>
Create an Expr
which calls the extension function with the given
Name
on args
Source§fn unary_app(self, op: impl Into<UnaryOp>, arg: Expr<T>) -> Expr<T>
fn unary_app(self, op: impl Into<UnaryOp>, arg: Expr<T>) -> Expr<T>
Create an application Expr
which applies the given built-in unary
operator to the given arg
Source§fn binary_app(
self,
op: impl Into<BinaryOp>,
arg1: Expr<T>,
arg2: Expr<T>,
) -> Expr<T>
fn binary_app( self, op: impl Into<BinaryOp>, arg1: Expr<T>, arg2: Expr<T>, ) -> Expr<T>
Create an application Expr
which applies the given built-in binary
operator to arg1
and arg2
Source§fn get_attr(self, expr: Expr<T>, attr: SmolStr) -> Expr<T>
fn get_attr(self, expr: Expr<T>, attr: SmolStr) -> Expr<T>
Create an Expr
which gets a given attribute of a given Entity
or record.
expr
must evaluate to either Entity or Record type
Source§fn has_attr(self, expr: Expr<T>, attr: SmolStr) -> Expr<T>
fn has_attr(self, expr: Expr<T>, attr: SmolStr) -> Expr<T>
Create an Expr
which tests for the existence of a given
attribute on a given Entity
or record.
expr
must evaluate to either Entity or Record type
Source§fn like(self, expr: Expr<T>, pattern: Pattern) -> Expr<T>
fn like(self, expr: Expr<T>, pattern: Pattern) -> Expr<T>
Create a ‘like’ expression.
expr
must evaluate to a String type
Source§fn is_entity_type(self, expr: Expr<T>, entity_type: EntityType) -> Expr<T>
fn is_entity_type(self, expr: Expr<T>, entity_type: EntityType) -> Expr<T>
Create an ‘is’ expression.
Source§type Data = T
type Data = T
()
if no data is stored.Source§fn loc(&self) -> Option<&Loc>
fn loc(&self) -> Option<&Loc>
Source§fn data(&self) -> &Self::Data
fn data(&self) -> &Self::Data
Source§fn with_maybe_source_loc(self, maybe_source_loc: Option<&Loc>) -> Self
fn with_maybe_source_loc(self, maybe_source_loc: Option<&Loc>) -> Self
l
, if l
is Some. An implementation
may ignore this if it cannot store source information.Source§fn new() -> Selfwhere
Self: Sized,
fn new() -> Selfwhere
Self: Sized,
Source§fn with_source_loc(self, l: &Loc) -> Selfwhere
Self: Sized,
fn with_source_loc(self, l: &Loc) -> Selfwhere
Self: Sized,
l
. An implementation may ignore this if
it cannot store source information.Source§fn is_in_entity_type(
self,
e1: Self::Expr,
entity_type: EntityType,
e2: Self::Expr,
) -> Self::Exprwhere
Self: Sized,
fn is_in_entity_type(
self,
e1: Self::Expr,
entity_type: EntityType,
e2: Self::Expr,
) -> Self::Exprwhere
Self: Sized,
_ is _ in _
expressionSource§fn noteq(self, e1: Self::Expr, e2: Self::Expr) -> Self::Exprwhere
Self: Sized,
fn noteq(self, e1: Self::Expr, e2: Self::Expr) -> Self::Exprwhere
Self: Sized,
Source§fn greater(self, e1: Self::Expr, e2: Self::Expr) -> Self::Exprwhere
Self: Sized,
fn greater(self, e1: Self::Expr, e2: Self::Expr) -> Self::Exprwhere
Self: Sized,
Source§fn greatereq(self, e1: Self::Expr, e2: Self::Expr) -> Self::Exprwhere
Self: Sized,
fn greatereq(self, e1: Self::Expr, e2: Self::Expr) -> Self::Exprwhere
Self: Sized,
Source§fn and_nary(
self,
first: Self::Expr,
others: impl IntoIterator<Item = Self::Expr>,
) -> Self::Exprwhere
Self: Sized,
fn and_nary(
self,
first: Self::Expr,
others: impl IntoIterator<Item = Self::Expr>,
) -> Self::Exprwhere
Self: Sized,
and
expression that may have more than two subexpressions (A && B && C)
or may have only one subexpression, in which case no &&
is performed at all.
Arguments must evaluate to Bool type. Read moreSource§fn or_nary(
self,
first: Self::Expr,
others: impl IntoIterator<Item = Self::Expr>,
) -> Self::Exprwhere
Self: Sized,
fn or_nary(
self,
first: Self::Expr,
others: impl IntoIterator<Item = Self::Expr>,
) -> Self::Exprwhere
Self: Sized,
or
expression that may have more than two subexpressions (A || B || C)
or may have only one subexpression, in which case no ||
is performed at all.
Arguments must evaluate to Bool type. Read moreSource§fn add_nary(
self,
first: Self::Expr,
other: impl IntoIterator<Item = (AddOp, Self::Expr)>,
) -> Self::Exprwhere
Self: Sized,
fn add_nary(
self,
first: Self::Expr,
other: impl IntoIterator<Item = (AddOp, Self::Expr)>,
) -> Self::Exprwhere
Self: Sized,
Source§fn mul_nary(
self,
first: Self::Expr,
other: impl IntoIterator<Item = Self::Expr>,
) -> Self::Exprwhere
Self: Sized,
fn mul_nary(
self,
first: Self::Expr,
other: impl IntoIterator<Item = Self::Expr>,
) -> Self::Exprwhere
Self: Sized,
Auto Trait Implementations§
impl<T> Freeze for ExprBuilder<T>where
T: Freeze,
impl<T> RefUnwindSafe for ExprBuilder<T>where
T: RefUnwindSafe,
impl<T> Send for ExprBuilder<T>where
T: Send,
impl<T> Sync for ExprBuilder<T>where
T: Sync,
impl<T> Unpin for ExprBuilder<T>where
T: Unpin,
impl<T> UnwindSafe for ExprBuilder<T>where
T: UnwindSafe,
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,
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