pub struct EscapeAttrValue<T: ?Sized> { /* private fields */ }Expand description
Escapes <, &, >, ', " when it appears in the formatted string.
§Examples
#[track_caller]
fn check(input: &str, escaped: &str) {
let mut buf = String::new();
let mut writer = format_xml::EscapeAttrValue::wrap(&mut buf);
writer.write_str(input).unwrap();
assert_eq!(buf, escaped);
}
check("", "");
check(" ", " ");
check("&", "&");
check(" &", " &");
check("& ", "& ");
check("hello", "hello");
check("'world'", "'world'");
check("pre<script>post", "pre<script>post");
check("&<>\"\'", "&<>"'");
check("&a'b<c>", "&a'b<c>");Implementations§
Source§impl<T: ?Sized + Write> EscapeAttrValue<T>
impl<T: ?Sized + Write> EscapeAttrValue<T>
pub fn wrap(v: &mut T) -> &mut EscapeAttrValue<T>
Trait Implementations§
Source§impl<T> From<T> for EscapeAttrValue<T>
impl<T> From<T> for EscapeAttrValue<T>
Auto Trait Implementations§
impl<T> Freeze for EscapeAttrValue<T>
impl<T> RefUnwindSafe for EscapeAttrValue<T>where
T: RefUnwindSafe + ?Sized,
impl<T> Send for EscapeAttrValue<T>
impl<T> Sync for EscapeAttrValue<T>
impl<T> Unpin for EscapeAttrValue<T>
impl<T> UnwindSafe for EscapeAttrValue<T>where
T: UnwindSafe + ?Sized,
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