🏷️ 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};
#[cfg(feature = "database")]
use crate::{db::*};
use crate::db::*;
use std::sync::RwLock;

View file

@ -25,18 +25,15 @@ impl AssetsTrait for HeadScript {
}
impl HeadScript {
pub fn named<S>(path: S) -> Self
where
S: Into<String>,
{
pub fn named(path: impl Into<String>) -> 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<String>) -> Self {
self.code = code.into().trim().to_owned();
self
}

View file

@ -25,18 +25,15 @@ impl AssetsTrait for HeadStyles {
}
impl HeadStyles {
pub fn named<S>(path: S) -> Self
where
S: Into<String>,
{
pub fn named(path: impl Into<String>) -> 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<String>) -> Self {
self.styles = styles.into().trim().to_owned();
self
}

View file

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

View file

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