aboutsummaryrefslogtreecommitdiffstats
path: root/askama_shared/src
diff options
context:
space:
mode:
authorLibravatar Dirkjan Ochtman <dirkjan@ochtman.nl>2017-09-07 20:42:55 +0200
committerLibravatar Dirkjan Ochtman <dirkjan@ochtman.nl>2017-09-07 20:42:55 +0200
commit7247a2526cd449c90f2d4d83d13520035b663fae (patch)
treee78db0ed4c80c9ce093fda36cbaa2a61350e7587 /askama_shared/src
parent7c29bf765fd666e61b9bc7d0eb40909b8e9002da (diff)
downloadaskama-7247a2526cd449c90f2d4d83d13520035b663fae.tar.gz
askama-7247a2526cd449c90f2d4d83d13520035b663fae.tar.bz2
askama-7247a2526cd449c90f2d4d83d13520035b663fae.zip
Rewrite escapable() to prevent duplication
Diffstat (limited to 'askama_shared/src')
-rw-r--r--askama_shared/src/escaping.rs9
1 files changed, 6 insertions, 3 deletions
diff --git a/askama_shared/src/escaping.rs b/askama_shared/src/escaping.rs
index a8a3559..99babfd 100644
--- a/askama_shared/src/escaping.rs
+++ b/askama_shared/src/escaping.rs
@@ -41,14 +41,17 @@ impl<T> Display for MarkupDisplay<T> where T: Display {
}
-fn escapable(b: &u8) -> bool {
- *b == b'<' || *b == b'>' || *b == b'&' || *b == b'"' || *b == b'\'' || *b == b'/'
+fn escapable(b: u8) -> bool {
+ match b {
+ b'<' | b'>' | b'&' | b'"' | b'\'' | b'/' => true,
+ _ => false,
+ }
}
pub fn escape(s: String) -> String {
let mut found = Vec::new();
for (i, b) in s.as_bytes().iter().enumerate() {
- if escapable(b) {
+ if escapable(*b) {
found.push(i);
}
}