docx_rust/formatting/
bold.rs1use hard_xml::{XmlRead, XmlWrite};
2
3use crate::__xml_test_suites;
4
5#[derive(Debug, Default, XmlRead, XmlWrite, Clone)]
14#[cfg_attr(test, derive(PartialEq))]
15#[xml(tag = "w:b")]
16pub struct Bold {
17 #[xml(attr = "w:val")]
18 pub value: Option<bool>,
19}
20
21#[derive(Debug, Default, XmlRead, XmlWrite, Clone)]
22#[cfg_attr(test, derive(PartialEq))]
23#[xml(tag = "w:bCs")]
24pub struct BoldComplex {
25 #[xml(attr = "w:val")]
26 pub value: Option<bool>,
27}
28
29impl<T: Into<Option<bool>>> From<T> for Bold {
30 fn from(val: T) -> Self {
31 Bold { value: val.into() }
32 }
33}
34
35__xml_test_suites!(
36 Bold,
37 Bold::default(),
38 r#"<w:b/>"#,
39 Bold::from(false),
40 r#"<w:b w:val="false"/>"#,
41 Bold::from(true),
42 r#"<w:b w:val="true"/>"#,
43);