pub struct Table { /* private fields */ }Expand description
A table of rows under column headers.
A table measures its columns, gives each one a width, and renders every cell at its column’s width:
- Each column starts at the widest cell it holds.
- When those widths and the frame fit, the table is exactly that wide.
- Otherwise the widest column that can still shrink narrows by 1 cell of width, again and again. A keep-words column never goes below its widest word, and a fold column never goes below its widest cluster. An ellipsis column can shrink to a width of 1 cell.
- When the narrowest widths still do not fit, an unframed table lets its
keep-words columns run past the width. A
Frame::Gridtable folds those columns instead, so its frame stays aligned. It folds only the columns that can fold alone to make it fit, so a short id keeps its word beside a long URL. - Each cell renders at its column’s width. An ellipsis cell ends in
…, and a numeric column aligns right. - Each column then narrows to its widest rendered line. After a column wraps, its widest line fills its width, so no blank strip runs down the whole column. A table sized to its content draws no wider than it needs. An ellipsis column that cut a cell keeps its width, since the cut cell fills it.
Narrowing never changes the lines: text wrapped at a width wraps the same at its own widest line.
A table with no rows and no header draws nothing and measures 0.
Implementations§
Source§impl Table
impl Table
Sourcepub fn new(columns: impl IntoIterator<Item = Column>) -> Self
pub fn new(columns: impl IntoIterator<Item = Column>) -> Self
A table with columns and no rows, drawn as a Frame::Grid with no
separation between rows.
Sourcepub fn frame(self, frame: Frame) -> Self
pub fn frame(self, frame: Frame) -> Self
Sets what the table draws around and between its columns, replacing
the default Frame::Grid.
Sourcepub fn row_separation(self, separation: RowSeparation) -> Self
pub fn row_separation(self, separation: RowSeparation) -> Self
Sets what separates consecutive rows, replacing the default
RowSeparation::None.
Sourcepub fn row<C: Into<Text>>(self, cells: impl IntoIterator<Item = C>) -> Self
pub fn row<C: Into<Text>>(self, cells: impl IntoIterator<Item = C>) -> Self
Sourcepub fn rows<C, R>(self, rows: impl IntoIterator<Item = R>) -> Self
pub fn rows<C, R>(self, rows: impl IntoIterator<Item = R>) -> Self
Adds every row of rows in order, as row adds one.
Trait Implementations§
Auto Trait Implementations§
impl Forget for Table
impl Freeze for Table
impl Move for Table
impl RefUnwindSafe for Table
impl Send for Table
impl Sync for Table
impl Unpin for Table
impl UnsafeUnpin for Table
impl UnwindSafe for Table
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more