aboutsummaryrefslogtreecommitdiffstats
path: root/askama_shared
diff options
context:
space:
mode:
authorLibravatar Dirkjan Ochtman <dirkjan@ochtman.nl>2018-07-10 14:38:48 +0100
committerLibravatar Dirkjan Ochtman <dirkjan@ochtman.nl>2018-07-10 14:38:48 +0100
commit3dd29b9f15720338d8e1face240d86dd1b6ed50e (patch)
tree8c6709597e687b9705505c068bb6e8880a0ec199 /askama_shared
parent3358036c5aaa946b68676baef0c250020df4aa43 (diff)
downloadaskama-3dd29b9f15720338d8e1face240d86dd1b6ed50e.tar.gz
askama-3dd29b9f15720338d8e1face240d86dd1b6ed50e.tar.bz2
askama-3dd29b9f15720338d8e1face240d86dd1b6ed50e.zip
Simplify handling of file open errors
Diffstat (limited to '')
-rw-r--r--askama_shared/src/path.rs7
1 files changed, 3 insertions, 4 deletions
diff --git a/askama_shared/src/path.rs b/askama_shared/src/path.rs
index 8152b5d..6468b91 100644
--- a/askama_shared/src/path.rs
+++ b/askama_shared/src/path.rs
@@ -17,13 +17,12 @@ pub fn get_template_source(tpl_path: &Path) -> String {
"template file '{}' does not exist",
tpl_path.to_str().unwrap()
));
+
let mut f = match File::open(&path) {
- Err(_) => {
- let msg = format!("unable to open template file '{}'", &path.to_str().unwrap());
- panic!(msg)
- }
+ Err(_) => panic!("unable to open template file '{}'", &path.to_str().unwrap()),
Ok(f) => f,
};
+
let mut s = String::new();
f.read_to_string(&mut s).unwrap();
if s.ends_with('\n') {