#[non_exhaustive]pub struct Config {
pub add_space_before_slash_in_empty_elements: bool,
}Expand description
A struct that holds a writer configuration.
Current writer configuration can be retrieved by calling Writer::config()
and changed by changing properties of the object returned by a call to
Writer::config_mut().
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.add_space_before_slash_in_empty_elements: boolWhether to add a space before the closing slash in empty elements. According to the W3C guidelines, this is recommended as for maximum compatibility.
When set to true, empty elements will be terminated with “ />”.
When set to false, empty elements will be terminated with “/>”.
Default: false
§Example
use quick_xml::reader::Reader;
use quick_xml::writer::Writer;
use std::io::Cursor;
let mut writer = Writer::new(Cursor::new(Vec::new()));
writer.config_mut().add_space_before_slash_in_empty_elements = true;
writer.create_element("tag")
.with_attribute(("attr1", "value1"))
.write_empty()
.unwrap();
let result = writer.into_inner().into_inner();
let expected = r#"<tag attr1="value1" />"#;
assert_eq!(result, expected.as_bytes());Trait Implementations§
impl Eq for Config
impl StructuralPartialEq for Config
Auto Trait Implementations§
impl Freeze for Config
impl RefUnwindSafe for Config
impl Send for Config
impl Sync for Config
impl Unpin for Config
impl UnsafeUnpin for Config
impl UnwindSafe for Config
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