Skip to main content

TableColumn

Struct TableColumn 

Source
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

Source

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"]).

Source

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).

Source

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.

Source

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.

Source

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

Source§

fn clone(&self) -> TableColumn

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for TableColumn

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for TableColumn

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl Eq for TableColumn

Source§

impl PartialEq for TableColumn

Source§

fn eq(&self, other: &TableColumn) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl StructuralPartialEq for TableColumn

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.