From 3dbae42adbc93a1353a7cbd9a9239bc8d289358b Mon Sep 17 00:00:00 2001 From: Fuwn Date: Sun, 16 Apr 2023 02:23:51 +0000 Subject: refactor: optimise more arguments --- crates/germ/src/convert.rs | 7 +++++-- crates/germ/src/meta.rs | 3 ++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/crates/germ/src/convert.rs b/crates/germ/src/convert.rs index bfab16d..22329d0 100644 --- a/crates/germ/src/convert.rs +++ b/crates/germ/src/convert.rs @@ -68,6 +68,9 @@ pub fn from_ast(source: &Ast, target: &Target) -> String { /// ); /// ``` #[must_use] -pub fn from_string(source: &str, target: &Target) -> String { - from_ast(&Ast::from_owned(&source), target) +pub fn from_string( + source: &(impl ToString + ?Sized), + target: &Target, +) -> String { + from_ast(&Ast::from_owned(&source.to_string()), target) } diff --git a/crates/germ/src/meta.rs b/crates/germ/src/meta.rs index 12c37cb..05ca817 100644 --- a/crates/germ/src/meta.rs +++ b/crates/germ/src/meta.rs @@ -82,7 +82,8 @@ impl Meta { /// ); /// ``` #[must_use] - pub fn from_string(meta: &str) -> Self { + pub fn from_string(meta: impl Into>) -> Self { + let meta = meta.into().to_string(); let mut metas = meta.split(';'); let mime = metas.next().unwrap_or("").to_string(); let mut parameters = HashMap::new(); -- cgit v1.2.3