//! The emitted template, compiled. //! //! `templates/contacts.html` is generated from the description by //! [`crate::staging::as_askama_template`] and is never hand-edited. Regenerate //! it with: //! //! ```text //! QUASI_EMIT_TEMPLATE=crates/quasi-bench/templates/contacts.html \ //! cargo run --release -p quasi-bench --features askama //! ``` //! //! This column is the point of the whole spike. The description is the source, //! the template is an intermediate nobody writes, and Askama compiles that //! intermediate to straight-line Rust. If this and the staged column are close, //! then a semantic starting point costs nothing over a compiled template and //! the residual can stay a data program; if this is much faster, the gap is //! enum dispatch and the answer is to generate code rather than a table. use askama::Template; use crate::fixture::{Buyer, Rows, Shared}; /// The context the generated template reads. /// /// Field names are the ones [`crate::staging::expr`] emits, so the template and /// this struct move together or the build fails, which is the failure mode to /// want. #[derive(Template)] #[template(path = "contacts.html")] pub(crate) struct Contacts<'a> { pub(crate) count: usize, pub(crate) buyers: &'a [Buyer], pub(crate) shared: &'a [Shared], } impl<'a> Contacts<'a> { #[must_use] pub(crate) fn new(rows: &'a Rows) -> Self { Self { count: rows.buyers.len(), buyers: &rows.buyers, shared: &rows.shared, } } }