TabulateOptions

Struct TabulateOptions 

Source
pub struct TabulateOptions {
Show 22 fields pub headers: Headers, pub table_format: TableFormatChoice, pub float_format: FormatSpec, pub int_format: FormatSpec, pub num_align: Option<Alignment>, pub str_align: Option<Alignment>, pub missing_values: MissingValues, pub show_index: ShowIndex, pub disable_numparse: bool, pub disable_numparse_columns: Option<Vec<usize>>, pub preserve_whitespace: bool, pub enable_widechars: bool, pub max_col_widths: Option<Vec<Option<usize>>>, pub max_header_col_widths: Option<Vec<Option<usize>>>, pub col_global_align: Option<Alignment>, pub col_align: Vec<Option<Alignment>>, pub headers_global_align: Option<Alignment>, pub headers_align: Vec<Option<HeaderAlignment>>, pub row_align: Vec<Option<RowAlignment>>, pub row_global_align: Option<RowAlignment>, pub break_long_words: bool, pub break_on_hyphens: bool,
}
Expand description

Builder-style configuration for tabulate.

Fields§

§headers: Headers

Header configuration.

§table_format: TableFormatChoice

Table format selection (either a named format or a custom specification).

§float_format: FormatSpec

Floating point number formatting.

§int_format: FormatSpec

Integer number formatting.

§num_align: Option<Alignment>

Alignment for numeric columns.

§str_align: Option<Alignment>

Alignment for string columns.

§missing_values: MissingValues

Replacement value for None/missing data.

§show_index: ShowIndex

Index column behaviour.

§disable_numparse: bool

Disable automatic detection of numeric values.

§disable_numparse_columns: Option<Vec<usize>>

Disable numeric parsing for specific columns (0-indexed).

§preserve_whitespace: bool

Preserve the original whitespace provided in the data.

§enable_widechars: bool

Treat East Asian wide characters using double-width measurements.

§max_col_widths: Option<Vec<Option<usize>>>

Maximum column widths (if any).

§max_header_col_widths: Option<Vec<Option<usize>>>

Maximum header column widths (if any).

§col_global_align: Option<Alignment>

Alignment override applied to every column.

§col_align: Vec<Option<Alignment>>

Alignment overrides per column.

§headers_global_align: Option<Alignment>

Alignment override for header row.

§headers_align: Vec<Option<HeaderAlignment>>

Alignment overrides per-header cell.

§row_align: Vec<Option<RowAlignment>>

Alignment override applied to rows.

§row_global_align: Option<RowAlignment>

Alignment override applied to all rows.

§break_long_words: bool

Control how long words are wrapped.

§break_on_hyphens: bool

Control whether words can be wrapped on hyphens.

Implementations§

Source§

impl TabulateOptions

Source

pub fn new() -> Self

Construct a new options builder with default configuration.

Examples found in repository?
examples/basic.rs (line 14)
3fn main() {
4    let planets = vec![
5        vec!["Planet", "Radius (km)", "Mass (10^24 kg)"],
6        vec!["Mercury", "2440", "0.330"],
7        vec!["Venus", "6052", "4.87"],
8        vec!["Earth", "6371", "5.97"],
9        vec!["Mars", "3390", "0.642"],
10    ];
11
12    let table = tabulate(
13        planets,
14        TabulateOptions::new()
15            .headers(Headers::FirstRow)
16            .table_format("grid"),
17    )
18    .expect("tabulation succeeds");
19
20    println!("{table}");
21}
Source

pub fn headers(self, headers: Headers) -> Self

Set explicit headers.

Examples found in repository?
examples/basic.rs (line 15)
3fn main() {
4    let planets = vec![
5        vec!["Planet", "Radius (km)", "Mass (10^24 kg)"],
6        vec!["Mercury", "2440", "0.330"],
7        vec!["Venus", "6052", "4.87"],
8        vec!["Earth", "6371", "5.97"],
9        vec!["Mars", "3390", "0.642"],
10    ];
11
12    let table = tabulate(
13        planets,
14        TabulateOptions::new()
15            .headers(Headers::FirstRow)
16            .table_format("grid"),
17    )
18    .expect("tabulation succeeds");
19
20    println!("{table}");
21}
Source

pub fn table_format<S: Into<String>>(self, format: S) -> Self

Set table format by name.

Examples found in repository?
examples/basic.rs (line 16)
3fn main() {
4    let planets = vec![
5        vec!["Planet", "Radius (km)", "Mass (10^24 kg)"],
6        vec!["Mercury", "2440", "0.330"],
7        vec!["Venus", "6052", "4.87"],
8        vec!["Earth", "6371", "5.97"],
9        vec!["Mars", "3390", "0.642"],
10    ];
11
12    let table = tabulate(
13        planets,
14        TabulateOptions::new()
15            .headers(Headers::FirstRow)
16            .table_format("grid"),
17    )
18    .expect("tabulation succeeds");
19
20    println!("{table}");
21}
Source

pub fn table_format_custom(self, format: TableFormat) -> Self

Supply a custom TableFormat.

Source

pub fn float_format(self, format: FormatSpec) -> Self

Set floating point format.

Source

pub fn int_format(self, format: FormatSpec) -> Self

Set integer format.

Source

pub fn num_align(self, align: Alignment) -> Self

Set numeric column alignment.

Source

pub fn col_global_align(self, align: Alignment) -> Self

Override alignment for all columns.

Source

pub fn str_align(self, align: Alignment) -> Self

Set string column alignment.

Source

pub fn missing_value<S: Into<String>>(self, value: S) -> Self

Set the placeholder for missing values.

Source

pub fn missing_values<I, S>(self, values: I) -> Self
where I: IntoIterator<Item = S>, S: Into<String>,

Set per-column placeholders for missing values.

Source

pub fn disable_numparse(self, disable: bool) -> Self

Control whether tabulate should attempt to parse numeric values.

Source

pub fn disable_numparse_columns<I>(self, columns: I) -> Self
where I: IntoIterator<Item = usize>,

Disable numeric parsing for specific columns (0-indexed).

Source

pub fn is_numparse_disabled(&self, column: Option<usize>) -> bool

Returns true if numeric parsing is disabled for the provided column.

Source

pub fn preserve_whitespace(self, preserve: bool) -> Self

Control whitespace preservation.

Source

pub fn enable_widechars(self, enable: bool) -> Self

Enable width calculations that treat East Asian wide characters as double width.

Source

pub fn show_index(self, show_index: ShowIndex) -> Self

Configure how the index column is displayed.

Source

pub fn max_col_widths(self, widths: Vec<Option<usize>>) -> Self

Set per-column maximum widths. Use None for columns without limits.

Source

pub fn max_col_width(self, width: usize) -> Self

Set the same maximum width for all columns.

Source

pub fn max_header_col_widths(self, widths: Vec<Option<usize>>) -> Self

Set per-column maximum header widths. Use None for unlimited columns.

Source

pub fn max_header_col_width(self, width: usize) -> Self

Set the same maximum width for all header columns.

Source

pub fn headers_mapping<I, K, V>(self, mapping: I) -> Self
where I: IntoIterator<Item = (K, V)>, K: Into<String>, V: Into<String>,

Provide a mapping from column keys to display headers.

Source

pub fn col_alignments<I>(self, aligns: I) -> Self
where I: IntoIterator<Item = Option<Alignment>>,

Provide per-column alignment overrides.

Source

pub fn headers_global_align(self, align: Alignment) -> Self

Override alignment for all headers.

Source

pub fn headers_alignments<I>(self, aligns: I) -> Self

Provide per-header alignment overrides.

Source

pub fn row_global_align(self, align: RowAlignment) -> Self

Override the default alignment for all data rows.

Source

pub fn row_alignments<I>(self, aligns: I) -> Self
where I: IntoIterator<Item = Option<RowAlignment>>,

Provide per-row alignment overrides.

Trait Implementations§

Source§

impl Clone for TabulateOptions

Source§

fn clone(&self) -> TabulateOptions

Returns a duplicate of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for TabulateOptions

Source§

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

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

impl Default for TabulateOptions

Source§

fn default() -> Self

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

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.