pub struct Closure {
pub is_async: bool,
pub arity: usize,
pub body: ClosureBody,
pub module: Rc<str>,
pub captures: Vec<(Rc<str>, Value)>,
}Expand description
A closure captures its environment by value at creation time.
Fields§
§is_async: bool§arity: usizeHow many parameters this closure declares.
The whole of its signature that anything outside the backend that
built it asks for, and the reason it is a number rather than the
parameter list it used to be. Every reader wanted a count:
crate::builtins::Callable::arity answers out of this,
Result.mapError reads it to decide whether to hand its callback the
error it is replacing, and builtins::expect_callback refuses a
callback of the wrong shape in one place rather than at every call
site that needs the check. None of them wanted a name, a default, a
type or a span, and issue #121 is where each was asked and answered.
It counts parameters, not arguments a call must supply: a defaulted
or a variadic parameter is one of these like any other, which is what
params.len() answered when this was a Vec<Param>.
body: ClosureBody§module: Rc<str>The module a closure body resolves names in.
captures: Vec<(Rc<str>, Value)>