style: add static typing
Diff
src/util/templating.rs | 11 ++++++-----
1 file changed, 6 insertions(+), 5 deletions(-)
@@ -1,4 +1,5 @@
use std::collections::HashMap;
use std::path::Path;
use std::path::PathBuf;
use std::str::FromStr;
use walkdir::WalkDir;
@@ -6,13 +7,13 @@ use minijinja::{Environment, context};
use crate::data::formats::RenderConfig;
pub fn get_templates(template: String) -> HashMap<String, String> {
let template_path = PathBuf::from_str(&template);
let template_path: PathBuf = PathBuf::from_str(&template).unwrap();
let mut templates: HashMap<String, String> = HashMap::new();
for path in WalkDir::new(template_path.unwrap()).into_iter().filter_map(|e| e.ok()) {
for path in WalkDir::new(template_path).into_iter().filter_map(|e| e.ok()) {
if path.metadata().unwrap().is_file() {
let relative_path = PathBuf::from(path.path());
let relative_path = relative_path.strip_prefix(&template).unwrap();
let full_path = path.path().display().to_string();
let relative_path: PathBuf = PathBuf::from(path.path());
let relative_path: &Path = relative_path.strip_prefix(&template).unwrap();
let full_path: String = path.path().display().to_string();
if let Ok(file) = std::fs::read_to_string(&full_path) {
templates.insert(relative_path.to_str().unwrap_or_default().to_string(), file);
}