Skip to main content

TableBuilder

Struct TableBuilder 

Source
pub struct TableBuilder { /* private fields */ }
Expand description

表格构建器(纯文字单元格)。

Implementations§

Source§

impl TableBuilder

Source

pub fn head<I, S>(&mut self, cells: I) -> &mut Self
where I: IntoIterator<Item = S>, S: Into<String>,

设表头。

Source

pub fn row<I, S>(&mut self, cells: I) -> &mut Self
where I: IntoIterator<Item = S>, S: Into<String>,

加一数据行。

Source

pub fn align<I: IntoIterator<Item = Align>>(&mut self, aligns: I) -> &mut Self

设各列对齐(从第 0 列起)。

Source

pub fn width(&mut self, col: usize, w: Length) -> &mut Self

给某列(0 起)限宽。

Source

pub fn col_style<R>( &mut self, col: usize, f: impl Fn(&mut StyleBuilder) -> R, ) -> &mut Self

整列(含表头)的文字样式。

Source

pub fn row_style<R>( &mut self, row: usize, f: impl Fn(&mut StyleBuilder) -> R, ) -> &mut Self

整行(数据行,0 起)的文字样式。

Source

pub fn cell_style<R>( &mut self, row: usize, col: usize, f: impl Fn(&mut StyleBuilder) -> R, ) -> &mut Self

单格(数据行 / 列,0 起)的文字样式。

Source

pub fn col_fill(&mut self, col: usize, hex: &str) -> &mut Self

整列(含表头)背景填色。

Source

pub fn row_fill(&mut self, row: usize, hex: &str) -> &mut Self

整行(数据行)背景填色。

Source

pub fn cell_fill(&mut self, row: usize, col: usize, hex: &str) -> &mut Self

单格(数据行 / 列)背景填色。

Source

pub fn pad_x(&mut self, px: f32) -> &mut Self

列内边距(单元格左右,逻辑像素);越小列越紧凑。

Source

pub fn pad_y(&mut self, px: f32) -> &mut Self

行内边距(单元格上下,逻辑像素);越小行越紧凑、行距越小。

Source

pub fn expand(&mut self) -> &mut Self

拉伸铺满可用宽(富余宽度按比例分给自适应列;全固定列则整体等比放大)。

Source

pub fn grid_outer(&mut self, on: bool) -> &mut Self

外框线开关。

Source

pub fn grid_vertical(&mut self, on: bool) -> &mut Self

列竖线开关。

Source

pub fn grid_horizontal(&mut self, on: bool) -> &mut Self

行横线开关。

Source

pub fn no_grid(&mut self) -> &mut Self

去掉所有网格线(外框 / 竖线 / 横线)。

Source

pub fn header_fill(&mut self, on: bool) -> &mut Self

表头浅底开关。

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