surrealdb-core 3.3.1

A scalable, distributed, collaborative, document-graph database, for the realtime web
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
use anyhow::Result;

use crate::ctx::FrozenContext;
use crate::dbs::ParameterCapturePass;
use crate::expr::closure::ClosureExpr;
use crate::val::{Closure, Value};

#[instrument(level = "trace", name = "ClosureExpr::compute", skip_all)]
pub(crate) async fn closure_expr_compute(this: &ClosureExpr, ctx: &FrozenContext) -> Result<Value> {
	let captures = ParameterCapturePass::capture(ctx, &this.body);

	Ok(Value::Closure(Box::new(Closure::Expr {
		args: this.args.clone(),
		returns: this.returns.clone(),
		captures,
		body: this.body.clone(),
	})))
}