pub struct LetFn;Trait Implementations§
Source§impl Function for LetFn
Binds local names to values and evaluates a final expression with those bindings.
impl Function for LetFn
Binds local names to values and evaluates a final expression with those bindings.
LET introduces lexical variables using name/value pairs, then returns the last expression.
§Remarks
- Arguments must be provided as
name, valuepairs followed by one final calculation expression. - Names are resolved as local identifiers and can shadow workbook-level names.
- Bindings are evaluated left-to-right, so later values can reference earlier bindings.
- Invalid names or malformed arity return
#VALUE!.
§Examples
title: "Bind intermediate values"
formula: "=LET(rate,0.08,price,125,price*(1+rate))"
expected: 135title: "Use LET with range calculations"
grid:
A1: 10
A2: 4
formula: "=LET(total,SUM(A1:A2),total*2)"
expected: 28title: "Nested LET supports shadowing"
formula: "=LET(x,2,LET(x,5,x)+x)"
expected: 7related:
- LAMBDA
- IF
- SUM
- INDEX
faq:
- q: "Can a LET binding reference a name defined later in the same LET?"
a: "No. LET evaluates name/value pairs left-to-right, so each binding can only use earlier bindings."
- q: "Does LET overwrite workbook or worksheet names permanently?"
a: "No. LET names are lexical and local to that formula evaluation; they only shadow outer names inside the LET expression."
- q: "Is LET itself volatile?"
a: "No. LET is deterministic unless one of its bound expressions calls a volatile function such as RAND."[formualizer-docgen:schema:start]
Name: LET
Type: LetFn
Min args: 3
Max args: variadic
Variadic: true
Signature: LET(
fn name(&self) -> &'static str
fn min_args(&self) -> usize
fn variadic(&self) -> bool
Source§fn dispatch<'a, 'b, 'c>(
&self,
args: &'c [ArgumentHandle<'a, 'b>],
ctx: &dyn FunctionContext<'b>,
) -> Result<CalcValue<'b>, ExcelError>
fn dispatch<'a, 'b, 'c>( &self, args: &'c [ArgumentHandle<'a, 'b>], ctx: &dyn FunctionContext<'b>, ) -> Result<CalcValue<'b>, ExcelError>
Dispatch to the unified evaluation path with automatic argument validation.
Source§fn eval<'a, 'b, 'c>(
&self,
args: &'c [ArgumentHandle<'a, 'b>],
_ctx: &dyn FunctionContext<'b>,
) -> Result<CalcValue<'b>, ExcelError>
fn eval<'a, 'b, 'c>( &self, args: &'c [ArgumentHandle<'a, 'b>], _ctx: &dyn FunctionContext<'b>, ) -> Result<CalcValue<'b>, ExcelError>
The unified evaluation path. Read more
fn namespace(&self) -> &'static str
fn volatile(&self) -> bool
fn arg_schema(&self) -> &'static [ArgSchema]
Source§fn aliases(&self) -> &'static [&'static str]
fn aliases(&self) -> &'static [&'static str]
Optional list of additional alias names (case-insensitive) that should resolve to this
function. Default: empty slice. Implementors can override to expose legacy names.
Returned slice must have ’static lifetime (typically a static array reference).
fn function_salt(&self) -> u64
Source§fn eval_reference<'a, 'b, 'c>(
&self,
_args: &'c [ArgumentHandle<'a, 'b>],
_ctx: &dyn FunctionContext<'b>,
) -> Option<Result<ReferenceType, ExcelError>>
fn eval_reference<'a, 'b, 'c>( &self, _args: &'c [ArgumentHandle<'a, 'b>], _ctx: &dyn FunctionContext<'b>, ) -> Option<Result<ReferenceType, ExcelError>>
Optional reference result path. Only called by the interpreter/engine
when the callsite expects a reference (e.g., range combinators, by-ref
argument positions, or spill sources). Read more
Auto Trait Implementations§
impl Freeze for LetFn
impl RefUnwindSafe for LetFn
impl Send for LetFn
impl Sync for LetFn
impl Unpin for LetFn
impl UnsafeUnpin for LetFn
impl UnwindSafe for LetFn
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
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