diff options
| author | Fuwn <[email protected]> | 2023-04-16 02:23:51 +0000 |
|---|---|---|
| committer | Fuwn <[email protected]> | 2023-04-16 02:23:51 +0000 |
| commit | 3dbae42adbc93a1353a7cbd9a9239bc8d289358b (patch) | |
| tree | 3b7a6cd0fea6faf70b8743aec43fc52b4f960bd1 | |
| parent | refactor(quick): optimise arguments (diff) | |
| download | germ-3dbae42adbc93a1353a7cbd9a9239bc8d289358b.tar.xz germ-3dbae42adbc93a1353a7cbd9a9239bc8d289358b.zip | |
refactor: optimise more arguments
| -rw-r--r-- | crates/germ/src/convert.rs | 7 | ||||
| -rw-r--r-- | 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<std::borrow::Cow<'static, str>>) -> 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(); |