Skip to main content

table_formatter/table/
mod.rs

1//! Core library and the main entry point.
2
3mod cell;
4mod content;
5mod settings;
6#[allow(clippy::module_inception)]
7mod table;
8
9use std::rc::Rc;
10
11pub use cell::*;
12use colored::ColoredString;
13pub use content::*;
14pub use settings::*;
15pub use table::*;
16
17/// Wrapper for formatting-functions.
18/// 
19/// All functions could be converted to [Normal::Boxed], if you don't care about performance, try [fmt!] macro.
20/// 
21/// [fmt!]: ../macro.fmt.html
22/// [Normal::Boxed]: #variant.Boxed
23#[derive(Clone)]
24pub enum FormatterFunc {
25    Normal(fn(ColoredString) -> ColoredString),
26    Boxed(Rc<Box<dyn Fn(ColoredString) -> ColoredString>>),
27}
28
29impl FormatterFunc {
30    fn run(&self, s: ColoredString) -> ColoredString {
31        match self {
32            FormatterFunc::Normal(f) => f(s),
33            FormatterFunc::Boxed(f) => f(s),
34        }
35    }
36}