summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Cargo.lock2
-rw-r--r--Cargo.toml2
-rw-r--r--src/template.rs18
3 files changed, 20 insertions, 2 deletions
diff --git a/Cargo.lock b/Cargo.lock
index 78e5ca1..c4124f8 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -10,7 +10,7 @@ checksum = "5454cda0d57db59778608d7a47bff5b16c6705598265869fb052b657f66cf05e"
[[package]]
name = "just_template"
-version = "0.1.1"
+version = "0.1.2"
dependencies = [
"just_fmt",
]
diff --git a/Cargo.toml b/Cargo.toml
index b74572a..42e6c3c 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -2,7 +2,7 @@
name = "just_template"
authors = ["Weicao-CatilGrass"]
description = "a tool for code gen via templates"
-version = "0.1.1"
+version = "0.1.2"
edition = "2024"
readme = "README.md"
diff --git a/src/template.rs b/src/template.rs
index 622f191..27e14df 100644
--- a/src/template.rs
+++ b/src/template.rs
@@ -30,6 +30,24 @@ impl From<String> for Template {
}
}
+impl<'a> From<&'a str> for Template {
+ fn from(s: &'a str) -> Self {
+ Template {
+ template_str: s.to_string(),
+ ..Default::default()
+ }
+ }
+}
+
+impl<'a> From<std::borrow::Cow<'a, str>> for Template {
+ fn from(s: std::borrow::Cow<'a, str>) -> Self {
+ Template {
+ template_str: s.into_owned(),
+ ..Default::default()
+ }
+ }
+}
+
impl std::fmt::Display for Template {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
let cloned = self.clone();