pub struct DataTable {
pub caption: String,
pub headers: Vec<String>,
pub column_types: Vec<ColumnType>,
pub rows: Vec<Vec<CellValue>>,
pub row_highlights: HashMap<usize, String>,
}Expand description
A rectangular table of CellValues with a header row and typed columns.
Fields§
§caption: StringTable caption / title.
headers: Vec<String>Column header labels.
column_types: Vec<ColumnType>Column types (must match headers length if non-empty).
rows: Vec<Vec<CellValue>>Data rows; each row must have the same length as headers.
row_highlights: HashMap<usize, String>Optional row highlighting: row index → CSS class or LaTeX command.
Implementations§
Source§impl DataTable
impl DataTable
Sourcepub fn new(caption: impl Into<String>, headers: Vec<String>) -> Self
pub fn new(caption: impl Into<String>, headers: Vec<String>) -> Self
Create an empty table with the given headers.
Sourcepub fn add_row(&mut self, row: Vec<CellValue>)
pub fn add_row(&mut self, row: Vec<CellValue>)
Append a row. Panics in debug builds if the row width doesn’t match headers.
Sourcepub fn set_column_type(&mut self, idx: usize, ct: ColumnType)
pub fn set_column_type(&mut self, idx: usize, ct: ColumnType)
Set the column type for column idx.
Sourcepub fn highlight_row(&mut self, idx: usize, label: impl Into<String>)
pub fn highlight_row(&mut self, idx: usize, label: impl Into<String>)
Highlight row idx with a label (e.g. "highlight", "\\rowcolor{yellow}").
Sourcepub fn column_widths(&self) -> Vec<usize>
pub fn column_widths(&self) -> Vec<usize>
Compute the maximum display-string width of each column (including header).
Trait Implementations§
Auto Trait Implementations§
impl Freeze for DataTable
impl RefUnwindSafe for DataTable
impl Send for DataTable
impl Sync for DataTable
impl Unpin for DataTable
impl UnsafeUnpin for DataTable
impl UnwindSafe for DataTable
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
The inverse inclusion map: attempts to construct
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
Checks if
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
Use with care! Same as
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
The inclusion map: converts
self to the equivalent element of its superset.