[][src]Struct ansi_to_html::Esc

pub struct Esc<T: AsRef<str>>(pub T);

A formatting wrapper for escaping HTML in a string.

The Display implementation replaces

  • & with &amp;
  • < with &lt;
  • > with &gt;
  • " with &quot;
  • ' with &#39;

Esc is lazy: If you don't use it, it does nothing. Also, it doesn't allocate a String unless you call .to_string().

Examples

In a format!-like macro:

assert_eq!(format!("{}", Esc("<h1>")).as_str(), "&lt;h1&gt;");

Convert it to a String directly:

assert_eq!(Esc("<h1>").to_string().as_str(), "&lt;h1&gt;");

Trait Implementations

impl<T: Clone + AsRef<str>> Clone for Esc<T>[src]

impl<T: Copy + AsRef<str>> Copy for Esc<T>[src]

impl<T: Debug + AsRef<str>> Debug for Esc<T>[src]

impl<T: AsRef<str>> Display for Esc<T>[src]

impl<T: Eq + AsRef<str>> Eq for Esc<T>[src]

impl<T: PartialEq + AsRef<str>> PartialEq<Esc<T>> for Esc<T>[src]

impl<T: AsRef<str>> StructuralEq for Esc<T>[src]

impl<T: AsRef<str>> StructuralPartialEq for Esc<T>[src]

Auto Trait Implementations

impl<T> RefUnwindSafe for Esc<T> where
    T: RefUnwindSafe

impl<T> Send for Esc<T> where
    T: Send

impl<T> Sync for Esc<T> where
    T: Sync

impl<T> Unpin for Esc<T> where
    T: Unpin

impl<T> UnwindSafe for Esc<T> where
    T: UnwindSafe

Blanket Implementations

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

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

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

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T> ToString for T where
    T: Display + ?Sized
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.