From f9ab0520576dc24eae878c065397dc517ebe5f6b Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Tue, 17 Sep 2024 17:29:56 +0200 Subject: [PATCH 1/3] Remove unneeded `as_f32` filter --- src/web/page/templates.rs | 4 ---- templates/crate/details.html | 4 ++-- templates/rustdoc/topbar.html | 4 ++-- 3 files changed, 4 insertions(+), 8 deletions(-) diff --git a/src/web/page/templates.rs b/src/web/page/templates.rs index b312160d2..c1f0bd6c8 100644 --- a/src/web/page/templates.rs +++ b/src/web/page/templates.rs @@ -263,10 +263,6 @@ pub mod filters { Ok(serde_json::to_string(value).expect("`encode_json` failed")) } - pub fn as_f32(value: &i32) -> rinja::Result { - Ok(*value as f32) - } - pub fn rest_menu_url(current_target: &str, inner_path: &str) -> rinja::Result { if current_target.is_empty() { return Ok(String::new()); diff --git a/templates/crate/details.html b/templates/crate/details.html index 18386f8dd..6d4e023db 100644 --- a/templates/crate/details.html +++ b/templates/crate/details.html @@ -26,8 +26,8 @@
    {%- if let (Some(documented), Some(total)) = (documented_items, total_items) -%} - {% set documented_f32 = documented|as_f32 %} - {% set total_f32 = total|as_f32 %} + {% set documented_f32 = documented as f32 %} + {% set total_f32 = total as f32 %} {% set percent = documented_f32 * 100f32 / total_f32 %}
  • Coverage
  • {{ percent|round(2) }}%
    diff --git a/templates/rustdoc/topbar.html b/templates/rustdoc/topbar.html index b7d11bd74..6e4eb116f 100644 --- a/templates/rustdoc/topbar.html +++ b/templates/rustdoc/topbar.html @@ -149,8 +149,8 @@
{%- if let (Some(documented), Some(total)) = (krate.documented_items, krate.total_items) -%} - {% set documented = documented|as_f32 %} - {% set total = total|as_f32 %} + {% set documented = documented as f32 %} + {% set total = total as f32 %} {% set percent = documented * 100f32 / total %}
From f56f18c1296e2bcbf7e317270fabb0dbd5917a84 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Tue, 17 Sep 2024 17:34:21 +0200 Subject: [PATCH 2/3] Remove unneeded `unwrap` filter --- src/web/page/templates.rs | 4 ---- templates/rustdoc/head.html | 2 +- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/src/web/page/templates.rs b/src/web/page/templates.rs index c1f0bd6c8..c648be86e 100644 --- a/src/web/page/templates.rs +++ b/src/web/page/templates.rs @@ -247,10 +247,6 @@ pub mod filters { } } - pub fn unwrap(value: &Option) -> rinja::Result<&T> { - Ok(value.as_ref().expect("`unwrap` filter failed")) - } - pub fn split_first<'a>(value: &'a str, pat: &str) -> rinja::Result> { Ok(value.split(pat).next()) } diff --git a/templates/rustdoc/head.html b/templates/rustdoc/head.html index 3320daa4a..a865b5bd7 100644 --- a/templates/rustdoc/head.html +++ b/templates/rustdoc/head.html @@ -1,5 +1,5 @@ {%- import "macros.html" as macros -%} - + From 2a775dc7a7000e8558b156da4d6a017a0cdaf40c Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Tue, 17 Sep 2024 17:35:41 +0200 Subject: [PATCH 3/3] Remove unneeded `to_string` filter --- src/web/page/templates.rs | 5 ----- templates/rustdoc/topbar.html | 2 +- 2 files changed, 1 insertion(+), 6 deletions(-) diff --git a/src/web/page/templates.rs b/src/web/page/templates.rs index c648be86e..3145fb3ab 100644 --- a/src/web/page/templates.rs +++ b/src/web/page/templates.rs @@ -92,7 +92,6 @@ pub mod filters { use chrono::{DateTime, Utc}; use rinja::filters::Safe; use std::borrow::Cow; - use std::fmt; // Copied from `tera`. pub fn escape_html(input: &str) -> rinja::Result> { @@ -251,10 +250,6 @@ pub mod filters { Ok(value.split(pat).next()) } - pub fn to_string(value: &T) -> rinja::Result { - Ok(value.to_string()) - } - pub fn json_encode(value: &T) -> rinja::Result { Ok(serde_json::to_string(value).expect("`encode_json` failed")) } diff --git a/templates/rustdoc/topbar.html b/templates/rustdoc/topbar.html index 6e4eb116f..7eb80f079 100644 --- a/templates/rustdoc/topbar.html +++ b/templates/rustdoc/topbar.html @@ -36,7 +36,7 @@ {%- include "clipboard.svg" -%} - {%- if metadata.req_version|to_string == "latest" -%} + {%- if metadata.req_version.to_string() == "latest" -%}