Skip to main content

standard_context

Function standard_context 

Source
pub fn standard_context() -> Context
Expand description

A context of its own for a REPL or a document to extend: a copy-on-write clone of the process’s one standard library registration, crate::prelude::StandardLibrary::context.

Measured on the bench box, optimized: registering the prelude takes 315 ms, a clone of the registered context about 1 µs.

What comes back is an independent value the caller may mutate freely; it shares the prelude’s tables until it writes, and a write copies exactly the table it touches. the_cached_prelude_is_indistinguishable_from_a_fresh_one pins it against a freshly registered one, and Repl::new starts from it.