docx_rust/formatting/
italics.rs

1use hard_xml::{XmlRead, XmlWrite};
2
3use crate::__xml_test_suites;
4
5/// Italics
6///
7/// ```rust
8/// use docx_rust::formatting::*;
9///
10/// let i = Italics::from(false);
11/// let i = Italics::from(true);
12/// ```
13#[derive(Debug, Default, XmlRead, XmlWrite, Clone)]
14#[cfg_attr(test, derive(PartialEq))]
15#[xml(tag = "w:i")]
16pub struct Italics {
17    #[xml(attr = "w:val")]
18    pub value: Option<bool>,
19}
20
21impl<T: Into<Option<bool>>> From<T> for Italics {
22    fn from(val: T) -> Self {
23        Italics { value: val.into() }
24    }
25}
26
27#[derive(Debug, Default, XmlRead, XmlWrite, Clone)]
28#[cfg_attr(test, derive(PartialEq))]
29#[xml(tag = "w:iCs")]
30pub struct ItalicsComplex {
31    #[xml(attr = "w:val")]
32    pub value: Option<bool>,
33}
34
35impl<T: Into<Option<bool>>> From<T> for ItalicsComplex {
36    fn from(val: T) -> Self {
37        ItalicsComplex { value: val.into() }
38    }
39}
40
41#[derive(Debug, Default, XmlRead, XmlWrite, Clone)]
42#[cfg_attr(test, derive(PartialEq))]
43#[xml(tag = "w:caps")]
44pub struct Caps {
45    #[xml(attr = "w:val")]
46    pub value: Option<bool>,
47}
48
49impl<T: Into<Option<bool>>> From<T> for Caps {
50    fn from(val: T) -> Self {
51        Caps { value: val.into() }
52    }
53}
54
55#[derive(Debug, Default, XmlRead, XmlWrite, Clone)]
56#[cfg_attr(test, derive(PartialEq))]
57#[xml(tag = "w:smallCaps")]
58pub struct SmallCaps {
59    #[xml(attr = "w:val")]
60    pub value: Option<bool>,
61}
62
63impl<T: Into<Option<bool>>> From<T> for SmallCaps {
64    fn from(val: T) -> Self {
65        SmallCaps { value: val.into() }
66    }
67}
68
69__xml_test_suites!(
70    Italics,
71    Italics::default(),
72    r#"<w:i/>"#,
73    Italics::from(false),
74    r#"<w:i w:val="false"/>"#,
75    Italics::from(true),
76    r#"<w:i w:val="true"/>"#,
77);