html_sys/tables/
col.rs

1/// The HTML `<col>` element
2///
3/// [MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/col)
4#[doc(alias = "col")]
5#[non_exhaustive]
6#[derive(Debug, Clone, PartialEq, Default)]
7pub struct TableColumn {
8    pub data_map: crate::DataMap,
9    global_attrs: crate::GlobalAttributes,
10    /// Number of columns spanned by the element
11    pub span: std::option::Option<std::borrow::Cow<'static, str>>,
12}
13impl crate::RenderElement for TableColumn {
14    fn write_opening_tag<W: std::fmt::Write>(&self, writer: &mut W) -> std::fmt::Result {
15        write!(writer, "<col")?;
16        if let Some(field) = self.span.as_ref() {
17            write!(writer, r#" span="{field}""#)?;
18        }
19        write!(writer, "{}", self.global_attrs)?;
20        write!(writer, "{}", self.data_map)?;
21        write!(writer, ">")?;
22        Ok(())
23    }
24    #[allow(unused_variables)]
25    fn write_closing_tag<W: std::fmt::Write>(&self, writer: &mut W) -> std::fmt::Result {
26        Ok(())
27    }
28}
29impl std::fmt::Display for TableColumn {
30    fn fmt(&self, writer: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
31        use crate::RenderElement;
32        self.write_opening_tag(writer)?;
33        self.write_closing_tag(writer)?;
34        Ok(())
35    }
36}
37impl std::ops::Deref for TableColumn {
38    type Target = crate::GlobalAttributes;
39    fn deref(&self) -> &Self::Target {
40        &self.global_attrs
41    }
42}
43impl std::ops::DerefMut for TableColumn {
44    fn deref_mut(&mut self) -> &mut Self::Target {
45        &mut self.global_attrs
46    }
47}