Struct Table

Source
pub struct Table {
    caption: String,
    array: Vec<Vec<String>>,
}
Expand description

A flexible table of arbitrary number of rows and columns, with a caption to describe the table within the process

Fields§

§caption: String

Descriptive string to display alongside the table

§array: Vec<Vec<String>>

The complete array of table data, with the Vec<Vec<>> representing Row<Col<>>

Example: to access the entire header (first) row of the table

array[0]

Example: to access the 8th column of the 10th row of the table

array[9][7]

All data in the table are stored as strings, as the ultimate destination for these data are in a formatted process document’s HTML text. These data are not intended to be numerically manipulated from this Table structure, but rather the assumption is that all of the numerical processing is already complete when these data are read into this structure.

Implementations§

Source§

impl Table

Public “get” functions give access to the private fields. Private “set/add” functions are used within this module to construct the fields from a “new” Table struct.

Source

pub fn new() -> Table

Empty string for the default caption, and an empty array for the default table data

Source

pub fn get_caption(&self) -> &String

Return reference to the table caption

Source

fn set_caption(&mut self, caption: &str)

Change the table caption field

Source

pub fn get_size(&self) -> (usize, usize)

Return a tuple with the number of rows and the number of columns in the table data array.

Assumptions:

  1. if there are zero rows, there are zero columns
  2. the number of columns in the first row is the number of columns that should be in every row
Source

pub fn get_row(&self, row_num: usize) -> Vec<String>

Return a vector with all cell contents for an indexed row number.

Example: to return the contents of the first row,

my_table.get_row(0)

Example: to return the conents of the 10th row,

my_table.get_row(9)

Source

fn add_row(&mut self, row: Vec<String>)

Append the bottom of the table data array with another row of data.

Assumptions:

  1. if this is the first row to be pushed, then it has the correct number of columns
  2. if this is not the first row, then columns will be added from left-to-right until the correct number of columns is reached
  3. if this new row has fewer than the correct number of columns, empty strings will fill in the righthand columns until the correct number is achieved

Auto Trait Implementations§

§

impl Freeze for Table

§

impl RefUnwindSafe for Table

§

impl Send for Table

§

impl Sync for Table

§

impl Unpin for Table

§

impl UnwindSafe for Table

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.