pub struct ComprehensionExpr {
pub iter_var: String,
pub iter_var2: String,
pub iter_range: Expr,
pub accu_var: String,
pub accu_init: Expr,
pub loop_condition: Expr,
pub loop_step: Expr,
pub result: Expr,
}Expand description
A comprehension expression for list/map processing.
Comprehensions are CEL’s powerful iteration construct, similar to list comprehensions in Python. They consist of iteration, accumulation, and result computation phases.
§Structure
A comprehension has:
- One or two iteration variables that range over a collection
- An accumulator variable that maintains state across iterations
- A loop condition that determines when to continue
- A loop step that updates the accumulator
- A result expression that produces the final value
§Examples
Single variable: [x * 2 | x in [1, 2, 3]]
iter_var:"x"iter_range:[1, 2, 3]- Result:
[2, 4, 6]
Two variables (map iteration): [k | k, v in {"a": 1, "b": 2}, v > 1]
iter_var:"k"(key)iter_var2:"v"(value)iter_range:{"a": 1, "b": 2}- Result:
["b"]
Fields§
§iter_var: StringThe first iteration variable name (required).
iter_var2: StringThe second iteration variable name (empty string if not used).
iter_range: ExprThe expression providing the collection to iterate over.
accu_var: StringThe accumulator variable name.
accu_init: ExprThe initial value of the accumulator.
loop_condition: ExprThe condition to continue iterating (often just true).
loop_step: ExprThe expression to update the accumulator each iteration.
result: ExprThe final expression computed from the accumulator.
Trait Implementations§
Source§impl Debug for ComprehensionExpr
impl Debug for ComprehensionExpr
Source§impl From<&ComprehensionExpr> for ComprehensionExpr
impl From<&ComprehensionExpr> for ComprehensionExpr
Source§fn from(value: &ComprehensionExpr) -> Self
fn from(value: &ComprehensionExpr) -> Self
Converts to this type from the input type.
Source§impl From<UniquePtr<ComprehensionExpr>> for ComprehensionExpr
impl From<UniquePtr<ComprehensionExpr>> for ComprehensionExpr
Source§fn from(value: UniquePtr<ComprehensionExpr>) -> Self
fn from(value: UniquePtr<ComprehensionExpr>) -> Self
Converts to this type from the input type.
Auto Trait Implementations§
impl Freeze for ComprehensionExpr
impl RefUnwindSafe for ComprehensionExpr
impl Send for ComprehensionExpr
impl Sync for ComprehensionExpr
impl Unpin for ComprehensionExpr
impl UnwindSafe for ComprehensionExpr
Blanket Implementations§
§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
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>
Converts
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>
Converts
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