Trait text_grid::RawCell

source ·
pub trait RawCell {
    // Required method
    fn fmt(&self, s: &mut String);

    // Provided methods
    fn style(&self) -> CellStyle { ... }
    fn style_for_body(&self) -> CellStyle { ... }
}
Expand description

A data structure that can be formatted into a cell.

Normally, cell() or cell! is used to create a value that implements RawCell.

If you implement RawCell for a type, you should also implement Cells for convenience.

use text_grid::*;
struct X(String);

impl RawCell for X {
    fn fmt(&self, s: &mut String) {
        s.push_str(&self.0);
    }
    fn style(&self) -> CellStyle {
        CellStyle::new().align_h(HorizontalAlignment::Right)
    }
}
impl Cells for X {
    fn fmt(f: &mut CellsFormatter<Self>) {
        f.content(Cell::new);
    }
}

Required Methods§

source

fn fmt(&self, s: &mut String)

Output the cell text to given buffer.

Provided Methods§

source

fn style(&self) -> CellStyle

Return cell’s style.

source

fn style_for_body(&self) -> CellStyle

Implementations on Foreign Types§

source§

impl RawCell for bool

source§

fn fmt(&self, s: &mut String)

source§

fn style_for_body(&self) -> CellStyle

source§

impl RawCell for char

source§

fn fmt(&self, s: &mut String)

source§

fn style_for_body(&self) -> CellStyle

source§

impl RawCell for i8

source§

fn fmt(&self, s: &mut String)

source§

fn style_for_body(&self) -> CellStyle

source§

impl RawCell for i16

source§

fn fmt(&self, s: &mut String)

source§

fn style_for_body(&self) -> CellStyle

source§

impl RawCell for i32

source§

fn fmt(&self, s: &mut String)

source§

fn style_for_body(&self) -> CellStyle

source§

impl RawCell for i64

source§

fn fmt(&self, s: &mut String)

source§

fn style_for_body(&self) -> CellStyle

source§

impl RawCell for i128

source§

fn fmt(&self, s: &mut String)

source§

fn style_for_body(&self) -> CellStyle

source§

impl RawCell for isize

source§

fn fmt(&self, s: &mut String)

source§

fn style_for_body(&self) -> CellStyle

source§

impl RawCell for str

source§

fn fmt(&self, s: &mut String)

source§

fn style_for_body(&self) -> CellStyle

source§

impl RawCell for u8

source§

fn fmt(&self, s: &mut String)

source§

fn style_for_body(&self) -> CellStyle

source§

impl RawCell for u16

source§

fn fmt(&self, s: &mut String)

source§

fn style_for_body(&self) -> CellStyle

source§

impl RawCell for u32

source§

fn fmt(&self, s: &mut String)

source§

fn style_for_body(&self) -> CellStyle

source§

impl RawCell for u64

source§

fn fmt(&self, s: &mut String)

source§

fn style_for_body(&self) -> CellStyle

source§

impl RawCell for u128

source§

fn fmt(&self, s: &mut String)

source§

fn style_for_body(&self) -> CellStyle

source§

impl RawCell for ()

source§

fn fmt(&self, _: &mut String)

source§

impl RawCell for usize

source§

fn fmt(&self, s: &mut String)

source§

fn style_for_body(&self) -> CellStyle

source§

impl RawCell for String

source§

fn fmt(&self, s: &mut String)

source§

fn style_for_body(&self) -> CellStyle

source§

impl<T: RawCell> RawCell for Option<T>

source§

fn fmt(&self, s: &mut String)

source§

fn style(&self) -> CellStyle

source§

fn style_for_body(&self) -> CellStyle

source§

impl<T: RawCell, E: RawCell> RawCell for Result<T, E>

source§

fn fmt(&self, s: &mut String)

source§

fn style(&self) -> CellStyle

source§

fn style_for_body(&self) -> CellStyle

source§

impl<T: ?Sized + RawCell> RawCell for &T

source§

fn fmt(&self, s: &mut String)

source§

fn style(&self) -> CellStyle

source§

fn style_for_body(&self) -> CellStyle

source§

impl<T: ?Sized + RawCell> RawCell for &mut T

source§

fn fmt(&self, s: &mut String)

source§

fn style(&self) -> CellStyle

source§

fn style_for_body(&self) -> CellStyle

Implementors§

source§

impl<T: RawCell> RawCell for Cell<T>