pretty_table/
lib.rs

1//! # pretty-table
2//!
3//! `pretty-table` is a Rust crate that provides a simple and convenient way to pretty print tables
4//! and write them to a file using data from 2-D vectors.
5//!
6//! ## Features
7//!
8//! - Create beautiful tables from vectors of data.
9//! - Customize table formatting, alignment, and styling.
10//! - Print tables to the console for easy visualization.
11//!
12//! ## Usage
13//!
14//! To use `pretty-table`, add it as a dependency in your `Cargo.toml` file:
15//!
16//! ```toml
17//! [dependencies]
18//! pretty-table = "0.1.0"
19//! ```
20//!
21//! ```rust
22//! use pretty_table::prelude::*;
23//!
24//! fn main() {
25//!     // define your table as 2-D vectors where all vectors must have `EQUAL` lengths
26//!     let table_data = vec![
27//!         vec!["Name", "Age", "Salary"], // header
28//!         vec!["Altmann", "45", "11.0k"],
29//!         vec!["Bezos", "32", "99.34k"],
30//!         vec!["Pichai", "56", "9.9m"],
31//!         vec!["Cook", "43", "8.2m"],
32//!     ];
33//!
34//!     // print to terminal/standard output
35//!     print_table!(table_data.clone());
36//!
37//!     // write to file
38//!     write_table_to_file("table.txt", table_data);
39//! }
40//! ```
41//!
42//! ## Contributing
43//!
44//! Contributions are welcome! If you have any suggestions, bug reports, or want to contribute code,
45//! please open an issue or submit a pull request on the [GitHub repository](https://github.com/vilayat-ali/pretty-table).
46//!
47//! ## License
48//!
49//! This crate is distributed under the terms of the MIT License. See the [LICENSE](https://github.com/Vilayat-Ali/pretty-table-rs/blob/main/LICENSE) file for details.
50
51pub mod error;
52pub mod prelude;
53pub mod table;
54
55pub struct TableOptions {
56    pub max_rows: Option<usize>,
57    pub max_cols: Option<usize>,
58    pub only_display_cols: Option<Vec<usize>>,
59}
60
61impl Default for TableOptions {
62    fn default() -> Self {
63        TableOptions {
64            max_rows: None,
65            max_cols: None,
66            only_display_cols: None,
67        }
68    }
69}