vista 0.0.2

A utility library for displaying and formatting arrays, matrices and tensors in the terminal.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
//! ### `Formatter` trait
//!
//! This module contains the `Formatter` trait that defines the formatting behavior for different display methods.

use std::fmt::{Display, Formatter, Result};

/// Defines how elements are formatted when displayed
pub trait ElementFormatter {
    /// Format an element and write it to the formatter
    fn format_element<T: Display>(&self, f: &mut Formatter<'_>, elem: &T, width: usize, is_last_in_row: bool) -> Result;

    /// Write spacing between arrays when displaying multiple arrays
    fn write_array_separator(&self, f: &mut Formatter<'_>) -> Result {
        write!(f, "  ")
    }
}