aboutsummaryrefslogtreecommitdiffstats
path: root/askama_derive/src/generator.rs
diff options
context:
space:
mode:
authorLibravatar René Kijewski <Kijewski@users.noreply.github.com>2022-06-15 22:57:18 +0200
committerLibravatar GitHub <noreply@github.com>2022-06-15 22:57:18 +0200
commitd4c13f5b4367fd3ca57fc14fdcf1d01694060c7a (patch)
treea5843b18e88a9690a8f95179e99925071b4445c1 /askama_derive/src/generator.rs
parent55d292ca22320a36589e1afdee1c650d5da3540d (diff)
downloadaskama-d4c13f5b4367fd3ca57fc14fdcf1d01694060c7a.tar.gz
askama-d4c13f5b4367fd3ca57fc14fdcf1d01694060c7a.tar.bz2
askama-d4c13f5b4367fd3ca57fc14fdcf1d01694060c7a.zip
Replace `&Option<Box<T>>` with `Option<&T>` (#696)
No need to work on references to references.
Diffstat (limited to 'askama_derive/src/generator.rs')
-rw-r--r--askama_derive/src/generator.rs10
1 files changed, 6 insertions, 4 deletions
diff --git a/askama_derive/src/generator.rs b/askama_derive/src/generator.rs
index d89d2da..fdc9cae 100644
--- a/askama_derive/src/generator.rs
+++ b/askama_derive/src/generator.rs
@@ -29,7 +29,7 @@ pub(crate) fn derive_template(input: TokenStream) -> TokenStream {
/// value as passed to the `template()` attribute.
fn build_template(ast: &syn::DeriveInput) -> Result<String, CompileError> {
let template_args = TemplateArgs::new(ast)?;
- let config_toml = read_config_file(&template_args.config_path)?;
+ let config_toml = read_config_file(template_args.config_path.as_deref())?;
let config = Config::new(&config_toml)?;
let input = TemplateInput::new(ast, &config, template_args)?;
let source: String = match input.source {
@@ -1287,7 +1287,9 @@ impl<'a> Generator<'a> {
Expr::Filter(name, ref args) => self.visit_filter(buf, name, args)?,
Expr::Unary(op, ref inner) => self.visit_unary(buf, op, inner)?,
Expr::BinOp(op, ref left, ref right) => self.visit_binop(buf, op, left, right)?,
- Expr::Range(op, ref left, ref right) => self.visit_range(buf, op, left, right)?,
+ Expr::Range(op, ref left, ref right) => {
+ self.visit_range(buf, op, left.as_deref(), right.as_deref())?
+ }
Expr::Group(ref inner) => self.visit_group(buf, inner)?,
Expr::Call(ref obj, ref args) => self.visit_call(buf, obj, args)?,
Expr::RustMacro(name, args) => self.visit_rust_macro(buf, name, args),
@@ -1639,8 +1641,8 @@ impl<'a> Generator<'a> {
&mut self,
buf: &mut Buffer,
op: &str,
- left: &Option<Box<Expr<'_>>>,
- right: &Option<Box<Expr<'_>>>,
+ left: Option<&Expr<'_>>,
+ right: Option<&Expr<'_>>,
) -> Result<DisplayWrap, CompileError> {
if let Some(left) = left {
self.visit_expr(buf, left)?;