Giter Club home page Giter Club logo

pretty-table-rs's Introduction

Your Image Description

Pretty Table is a Rust crate designed to make your life easier when it comes to formatting and displaying 2-D vectors in a visually appealing tabular format. Whether you're working with strings, numbers, or custom types that implement the Into<String> trait, Pretty Table has got you covered.

Features

  • Versatile Input: Works with any type that implements the Into<String> trait.

  • Beautiful Output: Transform your 2-D vectors into visually pleasing tables.

  • Console and File Output: Display your tables in the console or write them to a file effortlessly.

Installation

Add Pretty Table to your Cargo.toml file:

[dependencies]
pretty-table = "0.1.3"

Or, run the command at the root of your project

cargo add pretty-table

Usage

Consider this quick example to get started.

use pretty_table::prelude::*;

fn main() {
    // define your table as 2-D vectors where all vectors must have `EQUAL` lengths
    let table_data = vec![
        vec!["Name", "Age", "Salary"], // header
        vec!["Altmann", "45", "11.0k"],
        vec!["Bezos", "32", "99.34k"],
        vec!["Pichai", "56", "9.9m"],
        vec!["Cook", "43", "8.2m"],
    ];

    // print to terminal/standard output
    print_table!(table_data.clone());

    // write to file
    write_table_to_file("table.txt", table_data);
}

Output:

+=========+=====+========+
|  Name   | Age | Salary |
+=========+=====+========+
| Altmann | 45  | 11.0k  |
+---------+-----+--------+
|  Bezos  | 32  | 99.34k |
+---------+-----+--------+
| Pichai  | 56  |  9.9m  |
+---------+-----+--------+
|  Cook   | 43  |  8.2m  |
+---------+-----+--------+

Explore more examples at /examples directory in this repository.

Documentation

For more in-depth information, check out the documentation.

Contribution

We welcome contributions! If you have any ideas, bug fixes, or improvements, feel free to open an issue or submit a pull request.

License

This project is licensed under the MIT License.

pretty-table-rs's People

Contributors

vilayat-ali avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.