pub struct CtxStack { /* private fields */ }Expand description
Nunjucks-style frame stack: inner frames shadow outer; set updates the innermost existing binding.
Values are stored as Arc so repeated reads and shallow copies of bindings can share the same
Value allocation when the stack is cloned or merged (see Self::flatten).
Frame maps use [ahash::AHashMap] for faster string-key lookup on hot paths (many distinct variables).
Implementations§
Source§impl CtxStack
impl CtxStack
pub fn from_root(root: Map<String, Value>) -> Self
Sourcepub fn revision(&self) -> u64
pub fn revision(&self) -> u64
Monotonic counter; changes whenever template bindings or frames change.
pub fn push_frame(&mut self)
pub fn pop_frame(&mut self)
Sourcepub fn get_ref(&self, name: &str) -> Option<&Value>
pub fn get_ref(&self, name: &str) -> Option<&Value>
Borrows the innermost binding for name across frames (template context shadows outer).
pub fn get(&self, name: &str) -> Value
pub fn defined(&self, name: &str) -> bool
pub fn set(&mut self, name: &str, value: Value)
Trait Implementations§
Auto Trait Implementations§
impl Freeze for CtxStack
impl RefUnwindSafe for CtxStack
impl Send for CtxStack
impl Sync for CtxStack
impl Unpin for CtxStack
impl UnwindSafe for CtxStack
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