pub struct ScopeSnapshot { /* private fields */ }Expand description
A snapshot of the staging-related fields of EvalCtx. Used to save
and restore the staging context at scope boundaries (reify, reifyc,
reifyv, run_now, Catch).
Replaces the closure-passed run_scope pattern of the recursive
baseline with a value we can name, hold on a continuation, and
inspect in tests. The discipline is identical: every save must be
paired with exactly one restore.
level is not part of ScopeSnapshot because it’s saved
independently in RunNowExit — level only changes at run-now
boundaries, not at every reify scope.
Implementations§
Source§impl ScopeSnapshot
impl ScopeSnapshot
Sourcepub fn save(ctx: &mut EvalCtx) -> Self
pub fn save(ctx: &mut EvalCtx) -> Self
Save the current staging state. The saved block is taken via
mem::take — callers who want to start fresh in the new scope
will set ctx.block = Vec::new() afterwards (typically via
save_and_reset_block for ergonomics).
fun is Rc::cloned (O(1) refcount bump, not a structural copy).
Sourcepub fn save_and_reset_block(ctx: &mut EvalCtx) -> Self
pub fn save_and_reset_block(ctx: &mut EvalCtx) -> Self
Save and reset block to empty. Equivalent to:
let snap = ScopeSnapshot::save(ctx);
// ctx.block is already Vec::new() because mem::take left it empty.Provided for symmetry with save — most reify-style scopes want
the block reset, so this is the common path. Functionally
equivalent to plain save but more explicit at the call site.