Struct maud_htmlescape::Escaper[][src]

pub struct Escaper<'a>(_);
Expand description

An adapter that escapes HTML special characters.

The following characters are escaped:

  • & is escaped as &amp;
  • < is escaped as &lt;
  • > is escaped as &gt;
  • " is escaped as &quot;

All other characters are passed through unchanged.

Note: In versions prior to 0.13, the single quote (') was escaped as well.

Example

use std::fmt::Write;
let mut s = String::new();
write!(Escaper::new(&mut s), "<script>launchMissiles()</script>").unwrap();
assert_eq!(s, "&lt;script&gt;launchMissiles()&lt;/script&gt;");

Implementations

Creates an Escaper from a String.

Trait Implementations

Writes a string slice into this writer, returning whether the write succeeded. Read more

Writes a char into this writer, returning whether the write succeeded. Read more

Glue for usage of the write! macro with implementors of this trait. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.