From 3358036c5aaa946b68676baef0c250020df4aa43 Mon Sep 17 00:00:00 2001 From: Dirkjan Ochtman Date: Tue, 10 Jul 2018 14:38:32 +0100 Subject: Reorder items in top-down order --- askama_shared/src/path.rs | 44 ++++++++++++++++++++++---------------------- 1 file changed, 22 insertions(+), 22 deletions(-) (limited to 'askama_shared/src') diff --git a/askama_shared/src/path.rs b/askama_shared/src/path.rs index 6b3ed0c..8152b5d 100644 --- a/askama_shared/src/path.rs +++ b/askama_shared/src/path.rs @@ -54,32 +54,14 @@ pub fn find_template_from_path(path: &str, start_at: Option<&Path>) -> PathBuf { path.to_owned() } -static CONFIG_FILE_NAME: &str = "askama.toml"; - -#[derive(Deserialize)] -struct RawConfig { - dirs: Option>, +pub fn template_dirs() -> Vec { + Config::from_file().dirs } struct Config { dirs: Vec, } -impl RawConfig { - fn from_file(filename: &PathBuf) -> Option { - if filename.exists() { - let mut contents = String::new(); - File::open(filename) - .unwrap() - .read_to_string(&mut contents) - .unwrap(); - Some(toml::from_str(&contents).unwrap()) - } else { - None - } - } -} - impl Config { fn from_file() -> Config { let root = PathBuf::from(env::var("CARGO_MANIFEST_DIR").unwrap()); @@ -100,10 +82,28 @@ impl Config { } } -pub fn template_dirs() -> Vec { - Config::from_file().dirs +#[derive(Deserialize)] +struct RawConfig { + dirs: Option>, +} + +impl RawConfig { + fn from_file(filename: &PathBuf) -> Option { + if filename.exists() { + let mut contents = String::new(); + File::open(filename) + .unwrap() + .read_to_string(&mut contents) + .unwrap(); + Some(toml::from_str(&contents).unwrap()) + } else { + None + } + } } +static CONFIG_FILE_NAME: &str = "askama.toml"; + #[cfg(test)] mod tests { use super::Path; -- cgit