pub enum Entry<'a> {
Expr(&'a Expr),
Value(&'a Value),
}Variants§
Implementations§
Source§impl Entry<'_>
impl Entry<'_>
Sourcepub fn eval(&self, input: impl Input) -> Result<Value>
pub fn eval(&self, input: impl Input) -> Result<Value>
Evaluates the entry to a value using the provided input.
For Entry::Expr, evaluates the expression with the given input context.
For Entry::Value, returns a clone of the value directly.
§Examples
let value = Value::from(42);
let entry = Entry::from(&value);
let result = entry.eval(ConstInput::new()).unwrap();
assert_eq!(result, Value::from(42));Sourcepub fn eval_const(&self) -> Result<Value>
pub fn eval_const(&self) -> Result<Value>
Evaluates the entry as a constant expression.
For Entry::Expr, attempts to evaluate the expression without any input context.
This only succeeds if the expression is constant (contains no references or arguments).
For Entry::Value, returns a clone of the value directly.
§Errors
Returns an error if the entry contains an expression that cannot be evaluated as a constant (e.g., references to columns or arguments).
§Examples
let value = Value::from("hello");
let entry = Entry::from(&value);
let result = entry.eval_const().unwrap();
assert_eq!(result, Value::from("hello"));Sourcepub fn is_const(&self) -> bool
pub fn is_const(&self) -> bool
Returns true if the entry is a constant expression.
An entry is considered constant if it does not reference any external data:
Entry::Valueis always constantEntry::Expris constant if the expression itself is constant (seeExpr::is_constfor details)
Constant entries can be evaluated without any input context.
§Examples
// Values are always constant
let value = Value::from(42);
let entry = Entry::from(&value);
assert!(entry.is_const());
// Constant expressions
let expr = Expr::from(Value::from("hello"));
let entry = Entry::from(&expr);
assert!(entry.is_const());