docx_rust/formatting/
bold.rs

1use hard_xml::{XmlRead, XmlWrite};
2
3use crate::__xml_test_suites;
4
5/// Bold
6///
7/// ```rust
8/// use docx_rust::formatting::*;
9///
10/// let bold = Bold::from(false);
11/// let bold = Bold::from(true);
12/// ```
13#[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);