From f8f66f42ce88dca912bd6105bd63de0bea32c8e2 Mon Sep 17 00:00:00 2001 From: Dominic Date: Wed, 9 Jun 2021 15:32:10 +0200 Subject: [PATCH] fix other problems with askama's main branch --- codegen/src/main.rs | 7 +------ codegen/templates/src.rs.j2 | 2 +- codegen/templates/tests.rs.j2 | 4 ++-- 3 files changed, 4 insertions(+), 9 deletions(-) diff --git a/codegen/src/main.rs b/codegen/src/main.rs index ade8b839..5fc614d7 100644 --- a/codegen/src/main.rs +++ b/codegen/src/main.rs @@ -5,6 +5,7 @@ use bit_vec::BitVec; use linked_hash_map::LinkedHashMap; use num_format::{Locale, ToFormattedString}; use std::{ + borrow::Borrow, cmp::Ordering, collections::BTreeSet, convert::TryInto, @@ -31,12 +32,6 @@ const CHAR_RANGES: &[(char, char)] = &[ const MIN_ROWS: u32 = 4; const MAX_ROWS: u32 = 20; -mod filters { - pub fn chunks<'a>(src: &'a [u8], size: &usize) -> askama::Result> { - Ok(src.chunks(*size).collect()) - } -} - #[derive(Template)] #[template(path = "src.rs.j2", escape = "none")] struct RustSource<'a> { diff --git a/codegen/templates/src.rs.j2 b/codegen/templates/src.rs.j2 index aa5cc59f..863c9225 100644 --- a/codegen/templates/src.rs.j2 +++ b/codegen/templates/src.rs.j2 @@ -52,7 +52,7 @@ pub const FONT_{{ font.width }}x{{ font.height }}{% if font.bold %}_BOLD{% endif bitmap: ImageRaw::new_binary( // {{ font.img_width }} x {{ font.img_height }} ({{ font.bitmap_len }}) &[ - {%- for chunk in font.bitmap | chunks(16) %} + {%- for chunk in font.bitmap.chunks(16) %} {% for byte in chunk %}0x{{ "{:02x}"|format(byte) }}{% if !loop.last %}, {% endif %}{% endfor %} {%- if !loop.last %},{% endif %} {%- endfor %} diff --git a/codegen/templates/tests.rs.j2 b/codegen/templates/tests.rs.j2 index 01edbfdf..fe1cca29 100644 --- a/codegen/templates/tests.rs.j2 +++ b/codegen/templates/tests.rs.j2 @@ -103,7 +103,7 @@ test_font! { height: {{ font.height }}, a_pattern: &[ {%- for y in 0..font.height %} - "{{ font.glyph('a').mock_line(y) }}#{{ font.glyph('a').mock_line_inverted(y) }}#" + "{{ font.glyph('a'.borrow()).mock_line(y) }}#{{ font.glyph('a'.borrow()).mock_line_inverted(y) }}#" {%- if !loop.last %},{% endif %} {%- endfor %} ], @@ -117,7 +117,7 @@ test_font! { {%- endfor %} fallback_pattern: &[ {%- for y in 0..font.height %} - "{{ font.glyph('?').mock_line(y) }}{{ font.glyph('?').mock_line(y) }}{{ font.glyph('?').mock_line(y) }}" + "{{ font.glyph('?'.borrow()).mock_line(y) }}{{ font.glyph('?'.borrow()).mock_line(y) }}{{ font.glyph('?'.borrow()).mock_line(y) }}" {%- if !loop.last %},{% endif %} {%- endfor %} ]