🏷️ Improve ergonomic use of Into<String>

This commit is contained in:
Manuel Cillero 2023-07-17 19:50:55 +02:00
parent fefb3ed249
commit c123c3a780
5 changed files with 9 additions and 21 deletions

View file

@ -4,7 +4,7 @@ use crate::core::theme::all::THEMES;
use crate::{service, trace, LazyStatic}; use crate::{service, trace, LazyStatic};
#[cfg(feature = "database")] #[cfg(feature = "database")]
use crate::{db::*}; use crate::db::*;
use std::sync::RwLock; use std::sync::RwLock;

View file

@ -25,18 +25,15 @@ impl AssetsTrait for HeadScript {
} }
impl HeadScript { impl HeadScript {
pub fn named<S>(path: S) -> Self pub fn named(path: impl Into<String>) -> Self {
where
S: Into<String>,
{
HeadScript { HeadScript {
path: path.into(), path: path.into(),
..Default::default() ..Default::default()
} }
} }
pub fn with_code(mut self, code: &str) -> Self { pub fn with_code(mut self, code: impl Into<String>) -> Self {
self.code = code.trim().to_owned(); self.code = code.into().trim().to_owned();
self self
} }

View file

@ -25,18 +25,15 @@ impl AssetsTrait for HeadStyles {
} }
impl HeadStyles { impl HeadStyles {
pub fn named<S>(path: S) -> Self pub fn named(path: impl Into<String>) -> Self {
where
S: Into<String>,
{
HeadStyles { HeadStyles {
path: path.into(), path: path.into(),
..Default::default() ..Default::default()
} }
} }
pub fn with_styles(mut self, styles: &str) -> Self { pub fn with_styles(mut self, styles: impl Into<String>) -> Self {
self.styles = styles.trim().to_owned(); self.styles = styles.into().trim().to_owned();
self self
} }

View file

@ -41,10 +41,7 @@ impl AssetsTrait for JavaScript {
} }
impl JavaScript { impl JavaScript {
pub fn at<S>(path: S) -> Self pub fn at(path: impl Into<String>) -> Self {
where
S: Into<String>,
{
JavaScript { JavaScript {
path: path.into(), path: path.into(),
..Default::default() ..Default::default()

View file

@ -39,10 +39,7 @@ impl AssetsTrait for StyleSheet {
} }
impl StyleSheet { impl StyleSheet {
pub fn at<S>(path: S) -> Self pub fn at(path: impl Into<String>) -> Self {
where
S: Into<String>,
{
StyleSheet { StyleSheet {
path: path.into(), path: path.into(),
..Default::default() ..Default::default()