Skip to main content

RawCell

Trait 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

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl RawCell for ()

Source§

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

Source§

impl RawCell for String

Source§

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

Source§

fn style_for_body(&self) -> CellStyle

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 usize

Source§

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

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

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: RawCell> RawCell for Option<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>