Struct ansi_to_html::Esc
source · pub struct Esc<T: AsRef<str>>(pub T);
Expand description
A formatting wrapper for escaping HTML in a string.
The Display
implementation replaces
&
with&
<
with<
>
with>
"
with"
'
with'
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(), "<h1>");
Convert it to a String directly:
assert_eq!(Esc("<h1>").to_string().as_str(), "<h1>");
Tuple Fields§
§0: T
Trait Implementations§
source§impl<T: PartialEq + AsRef<str>> PartialEq for Esc<T>
impl<T: PartialEq + AsRef<str>> PartialEq for Esc<T>
impl<T: Copy + AsRef<str>> Copy for Esc<T>
impl<T: Eq + AsRef<str>> Eq for Esc<T>
impl<T: AsRef<str>> StructuralEq for Esc<T>
impl<T: AsRef<str>> StructuralPartialEq for Esc<T>
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§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more