-
Notifications
You must be signed in to change notification settings - Fork 312
Open
Description
Getting started documentation suggests to use lazy_static when it could suggest the more idiomatic way using std::sync::LazyLock (or OnceLock).
Changes
New version:
pub static TEMPLATES: Tera = std::sync::LazyLock::new(|| {
let mut tera = match Tera::new("examples/basic/templates/**/*") {
Ok(t) => t,
Err(e) => {
println!("Parsing error(s): {}", e);
::std::process::exit(1);
}
};
tera.autoescape_on(vec![".html", ".sql"]);
tera.register_filter("do_nothing", do_nothing_filter);
tera
});Old Version:
lazy_static! {
pub static ref TEMPLATES: Tera = {
let mut tera = match Tera::new("examples/basic/templates/**/*") {
Ok(t) => t,
Err(e) => {
println!("Parsing error(s): {}", e);
::std::process::exit(1);
}
};
tera.autoescape_on(vec![".html", ".sql"]);
tera.register_filter("do_nothing", do_nothing_filter);
tera
};
}Metadata
Metadata
Assignees
Labels
No labels