From 038884232b6efbabb414cb011fa0fc4e3b4c8fd6 Mon Sep 17 00:00:00 2001 From: Mike Buland Date: Sat, 13 Jun 2026 09:26:56 -0700 Subject: I did some silly things. This one doesn't build. --- src/context.rs | 18 ++++++++++++------ src/lib.rs | 11 +++++++++-- 2 files changed, 21 insertions(+), 8 deletions(-) diff --git a/src/context.rs b/src/context.rs index 7484a1f..d322411 100644 --- a/src/context.rs +++ b/src/context.rs @@ -39,21 +39,27 @@ impl MappedStructure for Context { } pub struct StatefulContext<'a, T: MappedStructure> { - root: &'a T, - current: &'a T, + pub root: &'a T, + local: &'a T, } impl<'a, T: MappedStructure> StatefulContext<'a, T> { pub fn root( root: &'a T ) -> Self { Self { - root, current: root, + root, local: root, } } - pub fn local(&self, current: &'a T ) -> Self { + pub fn local(&self, local: &'a T ) -> Self { Self { root: self.root, - current + local + } + } + + pub fn full( root: &'a T, local: &'a T ) -> Self { + Self { + root, local } } } @@ -66,7 +72,7 @@ impl<'a, T: MappedStructure> MappedStructure for StatefulContext<'a,T> { if id[0] == IdentifierValue::Root { self.root.get_value( &id[1..] ) } else { - self.current.get_value( id ) + self.local.get_value( id ) } } } diff --git a/src/lib.rs b/src/lib.rs index b413d2a..1ecd3b8 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -46,7 +46,7 @@ impl View { for output in &self.outputs { let mut buf = String::new(); let sc = StatefulContext::root( input ); - exec( &sc, &output.code, &mut buf )?; + exec::( &sc, &output.code, &mut buf )?; out_vars.insert( output.name.clone(), Value::String(buf) ); } Ok(out_vars) @@ -201,7 +201,14 @@ fn exec(input: &StatefulContext, tokens: &Vec, buf let Value::List(list) = value { for rec in &list { if let Value::Dictionary(d) = rec { - exec( &input.local(d), code, buf )? + if matches!(d, Context) && + matches!(input.root, Context) { + println!("Matches."); + } else { + println!("Doesn't match."); + + } + exec( &StatefulContext::full(input.root,d), code, buf )? } } } -- cgit v1.2.3