aboutsummaryrefslogtreecommitdiff
path: root/src/template.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/template.rs')
-rw-r--r--src/template.rs54
1 files changed, 0 insertions, 54 deletions
diff --git a/src/template.rs b/src/template.rs
deleted file mode 100644
index e368917..0000000
--- a/src/template.rs
+++ /dev/null
@@ -1,54 +0,0 @@
-use std::collections::HashMap;
-
-#[derive(Default, Clone)]
-pub struct Template {
- pub(crate) template_str: String,
- pub(crate) params: HashMap<String, String>,
- pub(crate) impl_params: HashMap<String, Vec<HashMap<String, String>>>,
-}
-
-impl Template {
- /// Add a parameter
- pub fn insert_param(&mut self, name: String, value: String) {
- self.params.insert(name, value);
- }
-
- /// Add an implementation block and return a HashMap to set its parameters
- pub fn add_impl(&mut self, impl_name: String) -> &mut Vec<HashMap<String, String>> {
- self.impl_params.entry(impl_name).or_default()
- }
-}
-
-impl From<String> for Template {
- fn from(s: String) -> Self {
- Template {
- template_str: s,
- ..Default::default()
- }
- }
-}
-
-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();
- write!(f, "{}", cloned.expand().unwrap_or_default())
- }
-}