From d4c13f5b4367fd3ca57fc14fdcf1d01694060c7a Mon Sep 17 00:00:00 2001 From: René Kijewski Date: Wed, 15 Jun 2022 22:57:18 +0200 Subject: Replace `&Option>` with `Option<&T>` (#696) No need to work on references to references. --- askama_derive/src/config.rs | 2 +- askama_derive/src/generator.rs | 10 ++++++---- 2 files changed, 7 insertions(+), 5 deletions(-) (limited to 'askama_derive/src') diff --git a/askama_derive/src/config.rs b/askama_derive/src/config.rs index 01f81a2..7764c70 100644 --- a/askama_derive/src/config.rs +++ b/askama_derive/src/config.rs @@ -249,7 +249,7 @@ struct RawEscaper<'a> { } pub(crate) fn read_config_file( - config_path: &Option, + config_path: Option<&str>, ) -> std::result::Result { let root = PathBuf::from(env::var("CARGO_MANIFEST_DIR").unwrap()); let filename = match config_path { 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 { 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>>, - right: &Option>>, + left: Option<&Expr<'_>>, + right: Option<&Expr<'_>>, ) -> Result { if let Some(left) = left { self.visit_expr(buf, left)?; -- cgit