| 1 | pub mod arrangementrust-analyzer cargo comfy-table 7.2.2 utils/arrangement/; |
| 2 | pub mod formattingrust-analyzer cargo comfy-table 7.2.2 utils/formatting/; |
| 3 | |
| 4 | use arrangementrust-analyzer cargo comfy-table 7.2.2 utils/arrangement/::arrange_contentrust-analyzer cargo comfy-table 7.2.2 utils/arrangement/arrange_content().; |
| 5 | use formattingrust-analyzer cargo comfy-table 7.2.2 utils/formatting/::{bordersrust-analyzer cargo comfy-table 7.2.2 utils/formatting/borders/::draw_bordersrust-analyzer cargo comfy-table 7.2.2 utils/formatting/borders/draw_borders()., content_formatrust-analyzer cargo comfy-table 7.2.2 utils/formatting/content_format/::format_contentrust-analyzer cargo comfy-table 7.2.2 utils/formatting/content_format/format_content().}; |
| 6 | |
| 7 | use craterust-analyzer cargo comfy-table 7.2.2 crate/::{ |
| 8 | Columnrust-analyzer cargo comfy-table 7.2.2 column/Column#, Tablerust-analyzer cargo comfy-table 7.2.2 table/Table#, |
| 9 | stylerust-analyzer cargo comfy-table 7.2.2 style/::{CellAlignmentrust-analyzer cargo comfy-table 7.2.2 style/cell/CellAlignment#, ColumnConstraintrust-analyzer cargo comfy-table 7.2.2 style/column/ColumnConstraint#}, |
| 10 | }; |
| 11 | |
| 12 | /// This struct is ONLY used when table.to_string() is called. |
| 13 | /// It's purpose is to store intermediate results, information on how to |
| 14 | /// arrange the table and other convenience variables. |
| 15 | /// |
| 16 | /// The idea is to have a place for all this intermediate stuff, without |
| 17 | /// actually touching the Column struct. |
| 18 | #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/macros/Debug:)] |
| 19 | pub struct ColumnDisplayInforust-analyzer cargo comfy-table 7.2.2 utils/ColumnDisplayInfo# { |
| 20 | pub paddingrust-analyzer cargo comfy-table 7.2.2 utils/ColumnDisplayInfo#padding.: (u16, u16), |
| 21 | pub delimiterrust-analyzer cargo comfy-table 7.2.2 utils/ColumnDisplayInfo#delimiter.: Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<char>, |
| 22 | /// The actual allowed content width after arrangement |
| 23 | pub content_widthrust-analyzer cargo comfy-table 7.2.2 utils/ColumnDisplayInfo#content_width.: u16, |
| 24 | /// The content alignment of cells in this column |
| 25 | pub cell_alignmentrust-analyzer cargo comfy-table 7.2.2 utils/ColumnDisplayInfo#cell_alignment.: Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<CellAlignmentrust-analyzer cargo comfy-table 7.2.2 style/cell/CellAlignment#>, |
| 26 | is_hiddenrust-analyzer cargo comfy-table 7.2.2 utils/ColumnDisplayInfo#is_hidden.: bool, |
| 27 | } |
| 28 | |
| 29 | impl ColumnDisplayInforust-analyzer cargo comfy-table 7.2.2 utils/ColumnDisplayInfo# { |
| 30 | pub fn newrust-analyzer cargo comfy-table 7.2.2 utils/impl#[ColumnDisplayInfo]new().(column: &Columnrust-analyzer cargo comfy-table 7.2.2 column/Column#, mut content_width: u16) -> Selfrust-analyzer cargo comfy-table 7.2.2 utils/impl#[ColumnDisplayInfo] { |
| 31 | // The min contend width may only be 1 |
| 32 | if content_width rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u16][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u16][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u16][`PartialEq<Self>`]eq().0 { |
| 33 | content_width = 1; |
| 34 | } |
| 35 | Selfrust-analyzer cargo comfy-table 7.2.2 utils/impl#[ColumnDisplayInfo] { |
| 36 | paddingrust-analyzer cargo comfy-table 7.2.2 utils/ColumnDisplayInfo#padding.: column.paddingrust-analyzer cargo comfy-table 7.2.2 column/Column#padding., |
| 37 | delimiterrust-analyzer cargo comfy-table 7.2.2 utils/ColumnDisplayInfo#delimiter.: column.delimiterrust-analyzer cargo comfy-table 7.2.2 column/Column#delimiter., |
| 38 | content_widthrust-analyzer cargo comfy-table 7.2.2 utils/ColumnDisplayInfo#content_width., |
| 39 | cell_alignmentrust-analyzer cargo comfy-table 7.2.2 utils/ColumnDisplayInfo#cell_alignment.: column.cell_alignmentrust-analyzer cargo comfy-table 7.2.2 column/Column#cell_alignment., |
| 40 | is_hiddenrust-analyzer cargo comfy-table 7.2.2 utils/ColumnDisplayInfo#is_hidden.: matchesrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/matches!!(column.constraintrust-analyzer cargo comfy-table 7.2.2 column/Column#constraint., Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(ColumnConstraintrust-analyzer cargo comfy-table 7.2.2 style/column/ColumnConstraint#::Hiddenrust-analyzer cargo comfy-table 7.2.2 style/column/ColumnConstraint#Hidden#)), |
| 41 | } |
| 42 | } |
| 43 | |
| 44 | pub fn widthrust-analyzer cargo comfy-table 7.2.2 utils/impl#[ColumnDisplayInfo]width().(&self) -> u16 { |
| 45 | self.content_widthrust-analyzer cargo comfy-table 7.2.2 utils/ColumnDisplayInfo#content_width. |
| 46 | .saturating_addrust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/impl#[u16]saturating_add().(self.paddingrust-analyzer cargo comfy-table 7.2.2 utils/ColumnDisplayInfo#padding..0) |
| 47 | .saturating_addrust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/impl#[u16]saturating_add().(self.paddingrust-analyzer cargo comfy-table 7.2.2 utils/ColumnDisplayInfo#padding..1) |
| 48 | } |
| 49 | } |
| 50 | |
| 51 | pub fn build_tablerust-analyzer cargo comfy-table 7.2.2 utils/build_table().(table: &Tablerust-analyzer cargo comfy-table 7.2.2 table/Table#) -> impl Iteratorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#<Itemrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#Item# = Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#> { |
| 52 | let display_info = arrange_contentrust-analyzer cargo comfy-table 7.2.2 utils/arrangement/arrange_content().(table); |
| 53 | let content = format_contentrust-analyzer cargo comfy-table 7.2.2 utils/formatting/content_format/format_content().(table, &display_info); |
| 54 | draw_bordersrust-analyzer cargo comfy-table 7.2.2 utils/formatting/borders/draw_borders().(table, &content, &display_info).into_iterrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][IntoIterator]into_iter().() |
| 55 | } |