pub struct TableColumn { /* private fields */ }Expand description
A column in a TableBlock.
A column carries its proportional width, the horizontal and vertical alignment applied to its cells’ content, and the style used to process and render that content.
Implementations§
Source§impl TableColumn
impl TableColumn
Sourcepub fn width(&self) -> usize
pub fn width(&self) -> usize
Returns the width of this column relative to the other columns in the
table. The default width is 1.
This value carries two different meanings depending on the table, and a caller that resolves columns to final sizes must check which applies:
- In an ordinary table (no column is autowidth),
the width is a proportional ratio. Each column’s share of the table
is its width divided by the sum of all the column widths, so
[cols="1,2,3"]yields shares of 1/6, 2/6, and 3/6. - When at least one column in the table is autowidth (its specifier uses
the special width value
~), the AsciiDoc specification instead reads these widths as literal percentages (100-based): in[cols="25,~,~"]the first column is 25% wide and the~columns are sized to their content.
The two cases are distinguished by whether any column in the table is
autowidth, which the caller can test with
table.columns().iter().any(TableColumn::is_autowidth).
When this column itself is autowidth, this width is not used to size the
column (the column is sized to its content instead). A column made
autowidth by the ~ specifier reports the default width of 1, but one
that inherits autowidth from the table’s autowidth option retains
whatever width its specifier set (e.g. 2 for the first column of
[%autowidth,cols="2,1"]).
Sourcepub fn is_autowidth(&self) -> bool
pub fn is_autowidth(&self) -> bool
Returns true if this column is sized to fit its content rather than to
a proportional width.
A column is autowidth when its column specifier uses the special width
value ~, or when the table as a whole carries the autowidth option
(in which case every column inherits the setting).
Sourcepub fn h_align(&self) -> HorizontalAlignment
pub fn h_align(&self) -> HorizontalAlignment
Returns the horizontal alignment applied to this column’s content.
The alignment comes from a horizontal alignment operator (<, >, or
^) on the column’s specifier and defaults to
HorizontalAlignment::Left.
Sourcepub fn v_align(&self) -> VerticalAlignment
pub fn v_align(&self) -> VerticalAlignment
Returns the vertical alignment applied to this column’s content.
The alignment comes from a vertical alignment operator (.<, .>, or
.^) on the column’s specifier and defaults to
VerticalAlignment::Top.
Sourcepub fn style(&self) -> ColumnStyle
pub fn style(&self) -> ColumnStyle
Returns the style applied to this column’s content.
The style comes from a style operator in the last position of the
column’s specifier (a, d, e, h, l, m, or s) and defaults
to ColumnStyle::Default.
Trait Implementations§
Source§impl Clone for TableColumn
impl Clone for TableColumn
Source§fn clone(&self) -> TableColumn
fn clone(&self) -> TableColumn
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for TableColumn
impl Debug for TableColumn
Source§impl Default for TableColumn
impl Default for TableColumn
impl Eq for TableColumn
Source§impl PartialEq for TableColumn
impl PartialEq for TableColumn
Source§fn eq(&self, other: &TableColumn) -> bool
fn eq(&self, other: &TableColumn) -> bool
self and other values to be equal, and is used by ==.