aboutsummaryrefslogtreecommitdiffstats
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
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.
-rw-r--r--askama_derive/src/config.rs2
-rw-r--r--askama_derive/src/generator.rs10
2 files changed, 7 insertions, 5 deletions
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<String>,
+ config_path: Option<&str>,
) -> std::result::Result<String, CompileError> {
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<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)?;