[][src]Struct maud::Escaper

pub struct Escaper<'a>(_);

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.


This example is not tested
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;");


impl<'a> Escaper<'a>[src]

pub fn new(buffer: &'a mut String) -> Escaper<'a>[src]

Creates an Escaper from a String.

Trait Implementations

impl<'a> Write for Escaper<'a>[src]

fn write_char(&mut self, c: char) -> Result<(), Error>1.1.0[src]

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

fn write_fmt(&mut self, args: Arguments) -> Result<(), Error>1.0.0[src]

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

Auto Trait Implementations

impl<'a> Send for Escaper<'a>

impl<'a> Unpin for Escaper<'a>

impl<'a> Sync for Escaper<'a>

impl<'a> !UnwindSafe for Escaper<'a>

impl<'a> RefUnwindSafe for Escaper<'a>

Blanket Implementations

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<T> BorrowMut<T> for T where
    T: ?Sized

impl<T> Borrow<T> for T where
    T: ?Sized

impl<T> Any for T where
    T: 'static + ?Sized

impl<T> Erased for T

impl<T> Typeable for T where
    T: Any

fn get_type(&self) -> TypeId

Get the TypeId of this object.

impl<T> UnsafeAny for T where
    T: Any

impl<T> IntoCollection<T> for T

impl<T, I> AsResult<T, I> for T where
    I: Input,