Skip to content

Commit

Permalink
Use char for patterns where possible
Browse files Browse the repository at this point in the history
  • Loading branch information
djc committed Dec 8, 2021
1 parent c35a2c0 commit 9531747
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions askama_shared/src/filters/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -193,15 +193,15 @@ pub fn format() {}
/// followed by a blank line becomes a paragraph break `<p>`.
pub fn linebreaks<T: fmt::Display>(s: T) -> Result<String> {
let s = s.to_string();
let linebroken = s.replace("\n\n", "</p><p>").replace("\n", "<br/>");
let linebroken = s.replace("\n\n", "</p><p>").replace('\n', "<br/>");

Ok(format!("<p>{}</p>", linebroken))
}

/// Converts all newlines in a piece of plain text to HTML line breaks
pub fn linebreaksbr<T: fmt::Display>(s: T) -> Result<String> {
let s = s.to_string();
Ok(s.replace("\n", "<br/>"))
Ok(s.replace('\n', "<br/>"))
}

/// Replaces only paragraph breaks in plain text with appropriate HTML
Expand Down
2 changes: 1 addition & 1 deletion askama_shared/src/generator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -981,7 +981,7 @@ impl<'a, S: std::hash::BuildHasher> Generator<'a, S> {
for s in mem::take(&mut self.buf_writable) {
match s {
Writable::Lit(s) => {
buf_format.write(&s.replace("{", "{{").replace("}", "}}"));
buf_format.write(&s.replace('{', "{{").replace('}', "}}"));
size_hint += s.len();
}
Writable::Expr(s) => {
Expand Down

0 comments on commit 9531747

Please sign in to comment.