Skip to content

Commit 953e44a

Browse files
committed
Remove the get_template function
1 parent 6aacb0c commit 953e44a

File tree

2 files changed

+17
-30
lines changed

2 files changed

+17
-30
lines changed

src/manifest.rs

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -46,23 +46,24 @@ pub fn split_input(
4646
} else {
4747
format!("fn main() -> Result<(), Box<dyn std::error::Error+Sync+Send>> {{\n {{\n {} }}\n Ok(())\n}}", source)
4848
};
49-
(manifest, source, templates::get_template("file")?, false)
50-
}
51-
Input::Expr(content) => {
52-
let template_buf = templates::get_template("expr")?;
53-
let (manifest, template_src) =
54-
find_embedded_manifest(template_buf).unwrap_or((Manifest::Toml(""), template_buf));
55-
(manifest, content.to_string(), template_src, true)
56-
}
57-
Input::Loop(content, count) => {
58-
let templ = if *count { "loop-count" } else { "loop" };
59-
(
60-
Manifest::Toml(""),
61-
content.to_string(),
62-
templates::get_template(templ)?,
63-
true,
64-
)
49+
(manifest, source, consts::FILE_TEMPLATE, false)
6550
}
51+
Input::Expr(content) => (
52+
Manifest::Toml(""),
53+
content.to_string(),
54+
consts::EXPR_TEMPLATE,
55+
true,
56+
),
57+
Input::Loop(content, count) => (
58+
Manifest::Toml(""),
59+
content.to_string(),
60+
if *count {
61+
consts::LOOP_COUNT_TEMPLATE
62+
} else {
63+
consts::LOOP_TEMPLATE
64+
},
65+
true,
66+
),
6667
};
6768

6869
let mut prelude_str;

src/templates.rs

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
/*!
22
This module contains code related to template support.
33
*/
4-
use crate::consts;
54
use crate::error::{MainError, MainResult};
65
use regex::Regex;
76
use std::collections::HashMap;
@@ -41,16 +40,3 @@ pub fn expand(src: &str, subs: &HashMap<&str, &str>) -> MainResult<String> {
4140
result.push_str(&src[anchor..]);
4241
Ok(result)
4342
}
44-
45-
/**
46-
Attempts to locate and load the contents of the specified template.
47-
*/
48-
pub fn get_template(name: &str) -> MainResult<&'static str> {
49-
Ok(match name {
50-
"expr" => consts::EXPR_TEMPLATE,
51-
"file" => consts::FILE_TEMPLATE,
52-
"loop" => consts::LOOP_TEMPLATE,
53-
"loop-count" => consts::LOOP_COUNT_TEMPLATE,
54-
_ => panic!("No such template: {name}"),
55-
})
56-
}

0 commit comments

Comments
 (0)