From c123c3a7805bf1125ab3936168324aaa7b35b810 Mon Sep 17 00:00:00 2001 From: Manuel Cillero Date: Mon, 17 Jul 2023 19:50:55 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=8F=B7=EF=B8=8F=20Improve=20ergonomic=20u?= =?UTF-8?q?se=20of=20Into?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pagetop/src/core/module/all.rs | 2 +- pagetop/src/html/assets/headscript.rs | 9 +++------ pagetop/src/html/assets/headstyles.rs | 9 +++------ pagetop/src/html/assets/javascript.rs | 5 +---- pagetop/src/html/assets/stylesheet.rs | 5 +---- 5 files changed, 9 insertions(+), 21 deletions(-) diff --git a/pagetop/src/core/module/all.rs b/pagetop/src/core/module/all.rs index e5bbcabb..9bd74c79 100644 --- a/pagetop/src/core/module/all.rs +++ b/pagetop/src/core/module/all.rs @@ -4,7 +4,7 @@ use crate::core::theme::all::THEMES; use crate::{service, trace, LazyStatic}; #[cfg(feature = "database")] -use crate::{db::*}; +use crate::db::*; use std::sync::RwLock; diff --git a/pagetop/src/html/assets/headscript.rs b/pagetop/src/html/assets/headscript.rs index 2cea8186..51c649ce 100644 --- a/pagetop/src/html/assets/headscript.rs +++ b/pagetop/src/html/assets/headscript.rs @@ -25,18 +25,15 @@ impl AssetsTrait for HeadScript { } impl HeadScript { - pub fn named(path: S) -> Self - where - S: Into, - { + pub fn named(path: impl Into) -> Self { HeadScript { path: path.into(), ..Default::default() } } - pub fn with_code(mut self, code: &str) -> Self { - self.code = code.trim().to_owned(); + pub fn with_code(mut self, code: impl Into) -> Self { + self.code = code.into().trim().to_owned(); self } diff --git a/pagetop/src/html/assets/headstyles.rs b/pagetop/src/html/assets/headstyles.rs index 9608d666..1a00430e 100644 --- a/pagetop/src/html/assets/headstyles.rs +++ b/pagetop/src/html/assets/headstyles.rs @@ -25,18 +25,15 @@ impl AssetsTrait for HeadStyles { } impl HeadStyles { - pub fn named(path: S) -> Self - where - S: Into, - { + pub fn named(path: impl Into) -> Self { HeadStyles { path: path.into(), ..Default::default() } } - pub fn with_styles(mut self, styles: &str) -> Self { - self.styles = styles.trim().to_owned(); + pub fn with_styles(mut self, styles: impl Into) -> Self { + self.styles = styles.into().trim().to_owned(); self } diff --git a/pagetop/src/html/assets/javascript.rs b/pagetop/src/html/assets/javascript.rs index e69a1ae1..526ab412 100644 --- a/pagetop/src/html/assets/javascript.rs +++ b/pagetop/src/html/assets/javascript.rs @@ -41,10 +41,7 @@ impl AssetsTrait for JavaScript { } impl JavaScript { - pub fn at(path: S) -> Self - where - S: Into, - { + pub fn at(path: impl Into) -> Self { JavaScript { path: path.into(), ..Default::default() diff --git a/pagetop/src/html/assets/stylesheet.rs b/pagetop/src/html/assets/stylesheet.rs index 2cc53a1e..b670f21e 100644 --- a/pagetop/src/html/assets/stylesheet.rs +++ b/pagetop/src/html/assets/stylesheet.rs @@ -39,10 +39,7 @@ impl AssetsTrait for StyleSheet { } impl StyleSheet { - pub fn at(path: S) -> Self - where - S: Into, - { + pub fn at(path: impl Into) -> Self { StyleSheet { path: path.into(), ..Default::default()