[−][src]Struct comfy_table::Column
A representation of a table's column. Useful for styling and specifying constraints how big a column should be.
- Content padding for cells in this column
- Constraints on how wide this column shall be
- Default alignment for cells in this column
Columns are generated when adding rows or a header to a table.
As a result columns can only be modified after the table is populated by some data.
use comfy_table::{Table, ColumnConstraint, CellAlignment}; let mut table = Table::new(); table.set_header(&vec!["one", "two"]); let mut column = table.get_column_mut(1).expect("This should be column two"); // Set the max width for all cells of this column to 20 characters. column.set_constraint(ColumnConstraint::MaxWidth(20)); // Set the left padding to 5 spaces and the right padding to 1 space column.set_padding((5, 1)); // Align content in all cells of this column to the center of the cell. column.set_cell_alignment(CellAlignment::Center);
Fields
index: usize
The index of the column
Implementations
impl Column
[src]
pub fn new(index: usize) -> Self
[src]
pub fn set_padding(&mut self, padding: (u16, u16)) -> &mut Self
[src]
Set the padding for all cells of this column.
Padding is provided in the form of (left, right).
Default is (1, 1)
.
pub fn set_delimiter(&mut self, delimiter: char) -> &mut Self
[src]
Set the delimiter used to split text for this column's cells.
A custom delimiter on a cell in will overwrite the column's delimiter.
The default is a simple space
.
pub fn get_max_content_width(&self) -> u16
[src]
Get the width in characters of the widest line in this column.
This doesn't include padding yet!
pub fn get_max_width(&self) -> u16
[src]
Get the maximum possible width for this column.
This means widest line in this column + padding
pub fn set_constraint(&mut self, constraint: ColumnConstraint) -> &mut Self
[src]
Constraints allow to influence the auto-adjustment behavior of columns.
This can be useful to counter undesired auto-adjustment of content in tables.
pub fn get_constraint(&self) -> Option<&ColumnConstraint>
[src]
Get the constraint that is used for this column.
pub fn remove_constraint(&mut self) -> &mut Self
[src]
Remove any constraint on this column
pub fn set_cell_alignment(&mut self, alignment: CellAlignment)
[src]
Set the alignment for content inside of cells for this column.
Note: Alignment on a cell will always overwrite the column's setting.
Trait Implementations
Auto Trait Implementations
impl RefUnwindSafe for Column
[src]
impl Send for Column
[src]
impl Sync for Column
[src]
impl Unpin for Column
[src]
impl UnwindSafe for Column
[src]
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,