ArrayBuilder

Struct ArrayBuilder 

Source
pub struct ArrayBuilder<T> { /* private fields */ }
Expand description

A builder for creating ArrayView instances from headers and raw data.

Implementations§

Source§

impl<T> ArrayBuilder<T>
where T: ToString + Clone,

Source

pub fn new() -> Self

Creates a new empty builder.

Source

pub fn row_header<S: Into<String>>(self, rows: Vec<S>) -> Self

Sets the row header labels.

Source

pub fn row_headers<S: Into<String>>(self, rows: Vec<S>) -> Self

Sets the row header labels.

Source

pub fn column_header<S: Into<String>>(self, columns: Vec<S>) -> Self

Sets the column header labels.

Source

pub fn column_headers<S: Into<String>>(self, columns: Vec<S>) -> Self

Sets the column header labels.

Source

pub fn row_header_orientation(self, alignment: HAlign) -> Self

Sets the row header alignment.

Source

pub fn column_header_orientation(self, alignment: HAlign) -> Self

Sets the column header alignment.

Source

pub fn data_orientation(self, alignment: HAlign) -> Self

Sets the data cell alignment.

Source

pub fn array_name<S: Into<String>>(self, name: S) -> Self

Sets the top-left array name.

Source

pub fn data(self, data: Vec<Vec<T>>) -> Self

Sets the raw row data.

Source

pub fn add_column<S: Into<String>>(self, column: S) -> Self

Adds a column header.

Source

pub fn add_column_with_default<S: Into<String>>( self, column: S, default: T, ) -> Self

Adds a column header and appends a default value to each existing row.

Source

pub fn add_row<S: Into<String>>(self, row: S, data: Vec<T>) -> Self

Builds the array view using usize column keys.

Source

pub fn remove_row(self) -> Self

Removes the last row, if any.

Source

pub fn remove_column(self) -> Self

Removes the last column, if any.

Source

pub fn build(self) -> ArrayView<ArrayDataRow<T>, usize>

Builds the array view using usize column keys.

Trait Implementations§

Source§

impl<T> Default for ArrayBuilder<T>

Source§

fn default() -> Self

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

Auto Trait Implementations§

§

impl<T> Freeze for ArrayBuilder<T>

§

impl<T> RefUnwindSafe for ArrayBuilder<T>
where T: RefUnwindSafe,

§

impl<T> Send for ArrayBuilder<T>
where T: Send,

§

impl<T> Sync for ArrayBuilder<T>
where T: Sync,

§

impl<T> Unpin for ArrayBuilder<T>
where T: Unpin,

§

impl<T> UnwindSafe for ArrayBuilder<T>
where T: UnwindSafe,

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.
Source§

impl<T> With for T

Source§

fn wrap_with<U, F>(self, f: F) -> U
where F: FnOnce(Self) -> U,

Calls the given closure and return the result. Read more
Source§

fn with<F>(self, f: F) -> Self
where F: FnOnce(&mut Self),

Calls the given closure on self.
Source§

fn try_with<E, F>(self, f: F) -> Result<Self, E>
where F: FnOnce(&mut Self) -> Result<(), E>,

Calls the given closure on self.
Source§

fn with_if<F>(self, condition: bool, f: F) -> Self
where F: FnOnce(&mut Self),

Calls the given closure if condition == true.