30 releases

0.12.3 Sep 21, 2023
0.12.1 Apr 19, 2023
0.12.0 Mar 30, 2023
0.11.3 Apr 21, 2022
0.0.1 Nov 21, 2014

#22 in Command-line interface

Download history 35617/week @ 2024-07-17 38846/week @ 2024-07-24 39552/week @ 2024-07-31 43571/week @ 2024-08-07 41800/week @ 2024-08-14 53118/week @ 2024-08-21 45650/week @ 2024-08-28 50093/week @ 2024-09-04 44189/week @ 2024-09-11 44007/week @ 2024-09-18 47334/week @ 2024-09-25 52828/week @ 2024-10-02 45296/week @ 2024-10-09 55639/week @ 2024-10-16 52232/week @ 2024-10-23 51944/week @ 2024-10-30

213,108 downloads per month
Used in 375 crates (50 directly)

MIT license

89KB
2K SLoC

pretty.rs

build Docs

Pretty printing combinators for Rust

Synopsis

This crate provides functionality for defining pretty printers. It is particularly useful for printing structured recursive data like trees.

The implementation was originally based on Larsen's SML translation (https://github.com/kfl/wpp) of Wadler's Haskell pretty printer (https://homepages.inf.ed.ac.uk/wadler/papers/prettier/prettier.pdf). It has since been modified in various ways to better fit Rust's programming model. In particular, it uses iteration rather than recursion and provides streaming output.

Documentation

See the generated API documentation here.

Requirements

  1. Rust
  2. Cargo

You can install both with the following:

$ curl -s https://static.rust-lang.org/rustup.sh | sudo sh

See Installation for further details.

Usage

$ cargo build                                          ## build library and binary
$ cargo run --example trees                            ## run the example (pretty trees)
$ cargo run --example colored --features termcolor     ## run the example (pretty colored output)
$ cargo bench                                          ## run benchmarks
$ cargo test                                           ## run tests

Dependencies

~1.2–8MB
~57K SLoC