From 49c77bfef99d4d27eef2cd50026ba24908be7796 Mon Sep 17 00:00:00 2001 From: Simon Bruder Date: Thu, 11 Jul 2024 23:17:22 +0200 Subject: [PATCH] Use owned strings for PageAction --- src/frontend/item.rs | 8 ++++---- src/frontend/item_class.rs | 8 ++++---- src/frontend/templates/helpers.rs | 8 ++++---- src/frontend/templates/mod.rs | 2 +- 4 files changed, 13 insertions(+), 13 deletions(-) diff --git a/src/frontend/item.rs b/src/frontend/item.rs index 0bb40c9..6473731 100644 --- a/src/frontend/item.rs +++ b/src/frontend/item.rs @@ -58,8 +58,8 @@ async fn show_item( page_title: Some(Box::new(item_name.clone())), page_actions: vec![ (templates::helpers::PageAction { - href: &format!("/item/{}/edit", item.id), - name: "Edit", + href: format!("/item/{}/edit", item.id), + name: "Edit".to_string(), }), ], ..Default::default() @@ -138,8 +138,8 @@ async fn list_items(pool: web::Data) -> actix_web::Result) -> actix_web::Result { - pub href: &'a str, - pub name: &'a str, +pub struct PageAction { + pub href: String, + pub name: String, } -impl Render for PageAction<'_> { +impl Render for PageAction { fn render(&self) -> Markup { html! { a .btn.btn-primary href=(self.href) { (self.name) } diff --git a/src/frontend/templates/mod.rs b/src/frontend/templates/mod.rs index 465d2f5..e9cf786 100644 --- a/src/frontend/templates/mod.rs +++ b/src/frontend/templates/mod.rs @@ -53,7 +53,7 @@ pub struct TemplateConfig<'a> { pub path: &'a str, pub title: Option<&'a str>, pub page_title: Option>, - pub page_actions: Vec>, + pub page_actions: Vec, pub extra_css: Vec>, pub extra_js: Vec>, }