diff options
Diffstat (limited to '')
-rw-r--r-- | askama_derive/src/generator.rs | 6 | ||||
-rw-r--r-- | testing/tests/inheritance.rs | 2 |
2 files changed, 7 insertions, 1 deletions
diff --git a/askama_derive/src/generator.rs b/askama_derive/src/generator.rs index f1e1174..49e5dda 100644 --- a/askama_derive/src/generator.rs +++ b/askama_derive/src/generator.rs @@ -1285,12 +1285,14 @@ where scopes: vec![HashSet::new()], } } + fn with_parent<'p>(parent: &'p SetChain<T>) -> SetChain<'p, T> { SetChain { parent: Some(parent), scopes: vec![HashSet::new()], } } + fn contains(&self, val: T) -> bool { self.scopes.iter().rev().any(|set| set.contains(&val)) || match self.parent { @@ -1298,15 +1300,19 @@ where None => false, } } + fn is_current_empty(&self) -> bool { self.scopes.last().unwrap().is_empty() } + fn insert(&mut self, val: T) { self.scopes.last_mut().unwrap().insert(val); } + fn push(&mut self) { self.scopes.push(HashSet::new()); } + fn pop(&mut self) { self.scopes.pop().unwrap(); assert!(!self.scopes.is_empty()); diff --git a/testing/tests/inheritance.rs b/testing/tests/inheritance.rs index c007dce..2dac362 100644 --- a/testing/tests/inheritance.rs +++ b/testing/tests/inheritance.rs @@ -303,4 +303,4 @@ struct LetChild {} fn test_let_block() { let t = LetChild {}; assert_eq!(t.render().unwrap(), "1"); -}
\ No newline at end of file +} |