Skip to main content

Table

Struct Table 

Source
pub struct Table {
    pub n: CellPos,
    pub h: CellPos,
    pub contents: Array2<Content>,
    pub areas: EnumMap<Area, AreaStyle>,
    pub borders: EnumMap<Border, BorderStyle>,
    pub rules: EnumMap<Axis2, Array2<Option<Border>>>,
    pub value_options: ValueOptions,
}
Expand description

A table.

Fields§

§n: CellPos

Number of rows and columns.

§h: CellPos

Table header rows and columns.

This is a subset of n, so h.x <= n.x and h.y <= n.y.

§contents: Array2<Content>

Table contents.

The array has n.x columns and n.y rows.

§areas: EnumMap<Area, AreaStyle>

Styles for areas of the table.

§borders: EnumMap<Border, BorderStyle>

Styles for borders in the table.

§rules: EnumMap<Axis2, Array2<Option<Border>>>

Horizontal (Axis2::Y) and vertical (Axis2::X) rules.

§value_options: ValueOptions

How to present values.

Implementations§

Source§

impl Table

Source

pub fn new( n: CellPos, headers: CellPos, areas: EnumMap<Area, AreaStyle>, borders: EnumMap<Border, BorderStyle>, value_options: impl Into<ValueOptions>, ) -> Self

Source

pub fn get(&self, coord: CellPos) -> CellRef<'_>

Source

pub fn get_rule(&self, axis: Axis2, pos: CellPos) -> Option<BorderStyle>

Source

pub fn put(&mut self, region: CellRect, inner: CellInner)

Source

pub fn h_line(&mut self, border: Border, x: Range<usize>, y: usize)

Source

pub fn v_line(&mut self, border: Border, x: usize, y: Range<usize>)

Source

pub fn draw_line( &mut self, border: Border, (a, a_value): (Axis2, usize), b_range: Range<usize>, )

Source

pub fn iter_x(&self, y: usize) -> XIter<'_>

Source

pub fn heading_region(&self, pos: CellPos) -> Option<HeadingRegion>

The heading region that pos is part of, if any.

Source

pub fn cells(&self) -> Cells<'_>

Iterates across all of the cells in the table, visiting each of them once in top-down, left-to-right order. Spanned cells are visited once, at the point in the iteration where their top-left cell would appear if they were not spanned.

Source

pub fn is_empty(&self) -> bool

Trait Implementations§

Source§

impl Debug for Table

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl Freeze for Table

§

impl RefUnwindSafe for Table

§

impl Send for Table

§

impl Sync for Table

§

impl Unpin for Table

§

impl UnsafeUnpin 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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

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.