From 6cce13f076bdd3e8d9b0bf888c0464a1af9df25f Mon Sep 17 00:00:00 2001 From: René Kijewski Date: Wed, 8 Jun 2022 12:52:00 +0200 Subject: Merge askama_derive into askama --- askama_shared/src/helpers/mod.rs | 48 ---------------------------------------- 1 file changed, 48 deletions(-) delete mode 100644 askama_shared/src/helpers/mod.rs (limited to 'askama_shared/src/helpers/mod.rs') diff --git a/askama_shared/src/helpers/mod.rs b/askama_shared/src/helpers/mod.rs deleted file mode 100644 index 79a1ada..0000000 --- a/askama_shared/src/helpers/mod.rs +++ /dev/null @@ -1,48 +0,0 @@ -use std::iter::{Enumerate, Peekable}; - -pub struct TemplateLoop -where - I: Iterator, -{ - iter: Peekable>, -} - -impl TemplateLoop -where - I: Iterator, -{ - #[inline] - pub fn new(iter: I) -> Self { - TemplateLoop { - iter: iter.enumerate().peekable(), - } - } -} - -impl Iterator for TemplateLoop -where - I: Iterator, -{ - type Item = (::Item, LoopItem); - - #[inline] - fn next(&mut self) -> Option<(::Item, LoopItem)> { - self.iter.next().map(|(index, item)| { - ( - item, - LoopItem { - index, - first: index == 0, - last: self.iter.peek().is_none(), - }, - ) - }) - } -} - -#[derive(Copy, Clone)] -pub struct LoopItem { - pub index: usize, - pub first: bool, - pub last: bool, -} -- cgit