Skip to main content

var

Function var 

Source
pub fn var(name: impl Into<FieldName>) -> Expression
Expand description

Creates an expression that reads the parameter name of the enclosing lambda.

It is only meaningful in the body of a Lambda. Anywhere else it fails to bind.

let expr = checked_add(var("x"), lit(1_i32));
assert_eq!(expr.to_string(), "(@x + 1i32)");
// Outside a lambda body, nothing gives `x` a value.
assert!(expr.bind(&DType::Primitive(PType::I32, Nullability::NonNullable)).is_err());